nxt_router.c (1402:6b8d8a11ff4f) nxt_router.c (1403:1cee885b7f10)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#include <nxt_router.h>

--- 1347 unchanged lines hidden (view full) ---

1356 offsetof(nxt_socket_conf_t, body_read_timeout),
1357 },
1358
1359 {
1360 nxt_string("send_timeout"),
1361 NXT_CONF_MAP_MSEC,
1362 offsetof(nxt_socket_conf_t, send_timeout),
1363 },
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#include <nxt_router.h>

--- 1347 unchanged lines hidden (view full) ---

1356 offsetof(nxt_socket_conf_t, body_read_timeout),
1357 },
1358
1359 {
1360 nxt_string("send_timeout"),
1361 NXT_CONF_MAP_MSEC,
1362 offsetof(nxt_socket_conf_t, send_timeout),
1363 },
1364
1365 {
1366 nxt_string("body_temp_path"),
1367 NXT_CONF_MAP_STR,
1368 offsetof(nxt_socket_conf_t, body_temp_path),
1369 },
1364};
1365
1366
1367static nxt_conf_map_t nxt_router_websocket_conf[] = {
1368 {
1369 nxt_string("max_frame_size"),
1370 NXT_CONF_MAP_SIZE,
1371 offsetof(nxt_websocket_conf_t, max_frame_size),

--- 20 unchanged lines hidden (view full) ---

1392{
1393 u_char *p;
1394 size_t size;
1395 nxt_mp_t *mp;
1396 uint32_t next;
1397 nxt_int_t ret;
1398 nxt_str_t name, path;
1399 nxt_app_t *app, *prev;
1370};
1371
1372
1373static nxt_conf_map_t nxt_router_websocket_conf[] = {
1374 {
1375 nxt_string("max_frame_size"),
1376 NXT_CONF_MAP_SIZE,
1377 offsetof(nxt_websocket_conf_t, max_frame_size),

--- 20 unchanged lines hidden (view full) ---

1398{
1399 u_char *p;
1400 size_t size;
1401 nxt_mp_t *mp;
1402 uint32_t next;
1403 nxt_int_t ret;
1404 nxt_str_t name, path;
1405 nxt_app_t *app, *prev;
1406 nxt_str_t *t;
1400 nxt_router_t *router;
1401 nxt_app_joint_t *app_joint;
1402 nxt_conf_value_t *conf, *http, *value, *websocket;
1403 nxt_conf_value_t *applications, *application;
1404 nxt_conf_value_t *listeners, *listener;
1405 nxt_conf_value_t *routes_conf, *static_conf;
1406 nxt_socket_conf_t *skcf;
1407 nxt_http_routes_t *routes;

--- 285 unchanged lines hidden (view full) ---

1693 skcf->proxy_timeout = 60 * 1000;
1694 skcf->proxy_send_timeout = 30 * 1000;
1695 skcf->proxy_read_timeout = 30 * 1000;
1696
1697 skcf->websocket_conf.max_frame_size = 1024 * 1024;
1698 skcf->websocket_conf.read_timeout = 60 * 1000;
1699 skcf->websocket_conf.keepalive_interval = 30 * 1000;
1700
1407 nxt_router_t *router;
1408 nxt_app_joint_t *app_joint;
1409 nxt_conf_value_t *conf, *http, *value, *websocket;
1410 nxt_conf_value_t *applications, *application;
1411 nxt_conf_value_t *listeners, *listener;
1412 nxt_conf_value_t *routes_conf, *static_conf;
1413 nxt_socket_conf_t *skcf;
1414 nxt_http_routes_t *routes;

--- 285 unchanged lines hidden (view full) ---

1700 skcf->proxy_timeout = 60 * 1000;
1701 skcf->proxy_send_timeout = 30 * 1000;
1702 skcf->proxy_read_timeout = 30 * 1000;
1703
1704 skcf->websocket_conf.max_frame_size = 1024 * 1024;
1705 skcf->websocket_conf.read_timeout = 60 * 1000;
1706 skcf->websocket_conf.keepalive_interval = 30 * 1000;
1707
1708 nxt_str_null(&skcf->body_temp_path);
1709
1701 if (http != NULL) {
1702 ret = nxt_conf_map_object(mp, http, nxt_router_http_conf,
1703 nxt_nitems(nxt_router_http_conf),
1704 skcf);
1705 if (ret != NXT_OK) {
1706 nxt_alert(task, "http map error");
1707 goto fail;
1708 }

--- 5 unchanged lines hidden (view full) ---

1714 nxt_nitems(nxt_router_websocket_conf),
1715 &skcf->websocket_conf);
1716 if (ret != NXT_OK) {
1717 nxt_alert(task, "websocket map error");
1718 goto fail;
1719 }
1720 }
1721
1710 if (http != NULL) {
1711 ret = nxt_conf_map_object(mp, http, nxt_router_http_conf,
1712 nxt_nitems(nxt_router_http_conf),
1713 skcf);
1714 if (ret != NXT_OK) {
1715 nxt_alert(task, "http map error");
1716 goto fail;
1717 }

--- 5 unchanged lines hidden (view full) ---

1723 nxt_nitems(nxt_router_websocket_conf),
1724 &skcf->websocket_conf);
1725 if (ret != NXT_OK) {
1726 nxt_alert(task, "websocket map error");
1727 goto fail;
1728 }
1729 }
1730
1731 t = &skcf->body_temp_path;
1732
1733 if (t->length == 0) {
1734 t->start = (u_char *) task->thread->runtime->tmp;
1735 t->length = nxt_strlen(t->start);
1736 }
1737
1722#if (NXT_TLS)
1723 value = nxt_conf_get_path(listener, &certificate_path);
1724
1725 if (value != NULL) {
1726 nxt_conf_get_string(value, &name);
1727
1728 tls = nxt_mp_get(mp, sizeof(nxt_router_tlssock_t));
1729 if (nxt_slow_path(tls == NULL)) {

--- 3023 unchanged lines hidden (view full) ---

4753{
4754}
4755
4756
4757static void
4758nxt_router_app_prepare_request(nxt_task_t *task,
4759 nxt_request_app_link_t *req_app_link)
4760{
1738#if (NXT_TLS)
1739 value = nxt_conf_get_path(listener, &certificate_path);
1740
1741 if (value != NULL) {
1742 nxt_conf_get_string(value, &name);
1743
1744 tls = nxt_mp_get(mp, sizeof(nxt_router_tlssock_t));
1745 if (nxt_slow_path(tls == NULL)) {

--- 3023 unchanged lines hidden (view full) ---

4769{
4770}
4771
4772
4773static void
4774nxt_router_app_prepare_request(nxt_task_t *task,
4775 nxt_request_app_link_t *req_app_link)
4776{
4761 nxt_buf_t *buf;
4777 nxt_fd_t fd;
4778 nxt_buf_t *buf, *body;
4762 nxt_int_t res;
4763 nxt_port_t *port, *c_port, *reply_port;
4764 nxt_apr_action_t apr_action;
4765
4766 nxt_assert(req_app_link->app_port != NULL);
4767
4768 port = req_app_link->app_port;
4769 reply_port = req_app_link->reply_port;

--- 42 unchanged lines hidden (view full) ---

4812 &req_app_link->msg_info.tracking,
4813 req_app_link->stream);
4814 if (nxt_slow_path(res != NXT_OK)) {
4815 nxt_request_app_link_error(req_app_link, 500,
4816 "Failed to get tracking area");
4817 goto release_port;
4818 }
4819
4779 nxt_int_t res;
4780 nxt_port_t *port, *c_port, *reply_port;
4781 nxt_apr_action_t apr_action;
4782
4783 nxt_assert(req_app_link->app_port != NULL);
4784
4785 port = req_app_link->app_port;
4786 reply_port = req_app_link->reply_port;

--- 42 unchanged lines hidden (view full) ---

4829 &req_app_link->msg_info.tracking,
4830 req_app_link->stream);
4831 if (nxt_slow_path(res != NXT_OK)) {
4832 nxt_request_app_link_error(req_app_link, 500,
4833 "Failed to get tracking area");
4834 goto release_port;
4835 }
4836
4820 res = nxt_port_socket_twrite(task, port, NXT_PORT_MSG_REQ_HEADERS,
4821 -1, req_app_link->stream, reply_port->id, buf,
4837 body = req_app_link->request->body;
4838 fd = (body != NULL && nxt_buf_is_file(body)) ? body->file->fd : -1;
4839
4840 res = nxt_port_socket_twrite(task, port,
4841 NXT_PORT_MSG_REQ_HEADERS
4842 | NXT_PORT_MSG_CLOSE_FD,
4843 fd,
4844 req_app_link->stream, reply_port->id, buf,
4822 &req_app_link->msg_info.tracking);
4823
4824 if (nxt_slow_path(res != NXT_OK)) {
4825 nxt_request_app_link_error(req_app_link, 500,
4826 "Failed to send message to application");
4827 goto release_port;
4828 }
4829
4845 &req_app_link->msg_info.tracking);
4846
4847 if (nxt_slow_path(res != NXT_OK)) {
4848 nxt_request_app_link_error(req_app_link, 500,
4849 "Failed to send message to application");
4850 goto release_port;
4851 }
4852
4853 if (fd != -1) {
4854 body->file->fd = -1;
4855 }
4856
4830release_port:
4831
4832 nxt_router_app_port_release(task, port, apr_action);
4833
4834 nxt_request_app_link_update_peer(task, req_app_link);
4835}
4836
4837

--- 308 unchanged lines hidden (view full) ---

5146 break;
5147 }
5148 }
5149
5150 buf = NULL;
5151 }
5152 }
5153
4857release_port:
4858
4859 nxt_router_app_port_release(task, port, apr_action);
4860
4861 nxt_request_app_link_update_peer(task, req_app_link);
4862}
4863
4864

--- 308 unchanged lines hidden (view full) ---

5173 break;
5174 }
5175 }
5176
5177 buf = NULL;
5178 }
5179 }
5180
5181 if (r->body != NULL && nxt_buf_is_file(r->body)) {
5182 lseek(r->body->file->fd, 0, SEEK_SET);
5183 }
5184
5154 return out;
5155}
5156
5157
5158static void
5159nxt_router_app_timeout(nxt_task_t *task, void *obj, void *data)
5160{
5161 nxt_app_t *app;

--- 184 unchanged lines hidden ---
5185 return out;
5186}
5187
5188
5189static void
5190nxt_router_app_timeout(nxt_task_t *task, void *obj, void *data)
5191{
5192 nxt_app_t *app;

--- 184 unchanged lines hidden ---