summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_router.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-03-17Fixing body fd access racing condition.Max Romanov1-16/+31
To avoid closing the body fd prematurely, the fd value is moved from the request struct to the app link. The body fd should not be closed immediately after the request is sent to the application due to possible request rescheduling.
2020-03-12Using disk file to store large request body.Max Romanov1-3/+34
This closes #386 on GitHub.
2020-03-12Moving request memory pool retain call after RPC data allocation.Max Romanov1-0/+15
If the call is done only after a successful RPC data allocation, its corresponding release call is not missed, which avoids a potential leak.
2020-03-06Round robin upstream added.Igor Sysoev1-0/+11
2020-03-04Refactored nxt_http_action.Igor Sysoev1-3/+5
2020-03-03Fixing request_app_link reference counting for delayed requests.Max Romanov1-9/+36
Router built with debug may stop with assertion during stalled requests re-schedule. This was caused by missing reference counting increment before nxt_router_port_select() call.
2020-02-03Fixed req_app_link reference counting on cancellation.Max Romanov1-16/+7
Re-scheduled req_app_link structures should have use_count exactly equal to the number of references from the application and port list. However, there's one extra usage decrement that occurs after the req_app_link is created because the use_count is initialised as 1. This patch removes all excess instances of the usage decrement that caused preliminary req_app_link release and router process crash. To reproduce the issue need to cause request rescheduling between 2 app processes. This issue was introduced in 61e9f23a566d.
2019-12-24Introducing port messages to notify about out of shared memory.Max Romanov1-0/+56
- OOSM (out of shared memory). Sent by application process to router when application reaches the limit of allocated shared memory and needs more. - SHM_ACK. Sent by router to application when the application's shared memory is released and the OOSM flag is enabled for the segment. This implements blocking mode (the library waits for SHM_ACK in case of out of shared memory condition and retries allocating the required memory amount) and non-blocking mode (the library notifies the application that it's out of shared memory and returns control to the application module that sets up the output queue and puts SHM_ACK in the main message loop).
2019-11-26Refactoring reference counting of req_app_link.Max Romanov1-34/+48
The reason for the change is that the req_app_link reference count was incorrect if the application crashed at start; in this case, the nxt_request_app_link_update_peer() function was never called. This closes #332 issue on GitHub.
2019-11-14Initial proxy support.Igor Sysoev1-1/+8
2019-11-14Introduced chained buffer completion handlers.Igor Sysoev1-2/+7
2019-11-14Replacing pass with action.Igor Sysoev1-7/+7
2019-10-10Style fixes.Igor Sysoev1-1/+2
2019-09-19Basic support for serving static files.Valentin Bartenev1-1/+92
2019-08-30Fixed WebSocket implementation that was broken on some systems.Max Romanov1-1/+1
The "nxt_http_websocket" request state, defined in "nxt_http_websocket.c", is used in "nxt_router.c" and must be linked with external symbol declared in "nxt_router.c". Due to the missing "extern" keyword, building Unit with some linkers (notably gold and LLD) caused WebSocket connections to get stuck or even crash the router process.
2019-08-26Adding body handler to nxt_http_request_header_send().Igor Sysoev1-6/+1
2019-08-20Introducing websocket support in router and libunit.Max Romanov1-71/+110
2019-08-16Changing the sequence of body send execution.Max Romanov1-2/+6
Request state ready_handler required for further websocket events processing. It is not required for regular response transferring.
2019-08-16Improving response header fields processing.Max Romanov1-8/+18
Fields are filtered one by one before being added to fields list. This avoids adding and then skipping connection-specific fields.
2019-08-14Renaming supplemental request structures in router.Max Romanov1-347/+418
- nxt_req_app_link_t -> nxt_request_app_link_t - nxt_req_conn_link_t -> nxt_request_rpc_data_t Corresponding abbreviated field names also changed: - ra -> req_app_link - rc -> req_rpc_data
2019-08-06Router: allowed empty configurations.Valentin Bartenev1-191/+189
Now it's possible to delete "listeners" and "applications" objects. This closes #187 issue on GitHub.
2019-08-06Refactored HTTP protocol callback table.Igor Sysoev1-1/+1
2019-06-28Fixed application crash handling in router.Max Romanov1-4/+4
Before this fix, request in router may hang until timeout expired if application crashed during request processing.
2019-03-21Adjusting request schema value according to connection tls state.Max Romanov1-0/+2
This closes #223 issue on GitHub.
2019-03-18Removing unused local variable.Max Romanov1-7/+0
2019-03-06Removed unnecessary abstraction layer.Alexander Borisov1-101/+114
2019-02-28Introducing Java Servlet Container beta.Max Romanov1-0/+1
2019-02-28Removing app data debug message.Max Romanov1-4/+0
This message produces too many noise in log and complicates analysis.
2019-02-27Fixed processing of SERVER_NAME after 77aad2c142a0.Valentin Bartenev1-11/+13
Previously, the nxt_router_prepare_msg() function expected server host among other headers unmodified. It's not true anymore since normalization of the Host header has been introduced in 77aad2c142a0. The nxt_unit_split_host() function was removed. It didn't work correctly with IPv6 literals. Anyway, after 77aad2c142a0 the port splitting is done in router while Host header processing.
2019-02-27Initial routing implementation.Igor Sysoev1-29/+45
2019-02-25Disabled useless code in nxt_router_listen_socket_error().Valentin Bartenev1-4/+8
It doesn't do anything useful, among creating a JSON message and logging it to debug log. Besides that it causes segmentation fault if the RPC handler is triggered with an empty buffer due to exiting of the main process.
2019-02-22TLS certificates should be freed per listener.Igor Sysoev1-6/+9
This fixes memory leak if configuration uses more than one TLS cerificate.
2019-02-18Fixed memory leak on response body sending failure.Igor Sysoev1-1/+1
2018-10-22Handling of timers with bias.Valentin Bartenev1-2/+2
Timers that don't require maximum precision (most of them, actually) can be triggered earlier or later within the bias interval. To reduce wakeups by timers, the expire function now triggers not only all timers that fall within the elapsed time, but also those whose bias falls within this interval.
2018-10-09Renamed "go" application type to "external".Valentin Bartenev1-1/+1
There's nothing specific to Go language. This type of application object can be used to run any external application that utilizes libunit API.
2018-09-20Preventing port from release in asynchronous operations.Max Romanov1-0/+12
Router reconfiguration may lead to starting new application processes, opening listen ports etc. These actions are asynchronous and require message exchange with master process. Router stores reference for controller (response) port in structure associated with reconfiguration process (tmcf). The port used to provide reconfiguration response (either success or failed) to controller. This commit increases response port use counter to make sure port structure not freed while router waits for result of asynchronous operations.
2018-09-20Controller: certificates storage interface.Valentin Bartenev1-0/+136
2018-09-20Added SSL/TLS support on connection level.Igor Sysoev1-0/+18
2018-09-19Initializing application structure with 0 to avoid crash.Max Romanov1-2/+7
Attribute 'application' is optional in listener object. This commit adds missing code to reset 'lscf' to avoid garbage and crash when the attribute is absent.
2018-08-10Introducing app joint to accurate app release.Max Romanov1-86/+157
For accurate app descriptor release, it is required to count the number of use counts. Use count increased when: - app linked to configuration app queue; - socket conf stores pointer to app; - request for start app process posted to router service thread; Application port has pointer to app, but it does not increase use count to avoid use count loop. Timer needs a pointer to nxt_timer_t which is stored in engine timers tree. nxt_timer_t now resides in nxt_app_joint_t and does not lock the application. Start process port RPC handlers is also linked to nxt_app_joint_t. App joint (nxt_app_joint_t) is a 'weak pointer': - single threaded; - use countable; - store pointer to nxt_app_t (which can be NULL); nxt_app_t has pointer to nxt_app_joint_t and update its pointer to app.
2018-08-06Unit application library.Max Romanov1-360/+295
Library now used in all language modules. Old 'nxt_app_*' code removed. See src/test/nxt_unit_app_test.c for usage sample.
2018-07-09Controller: added "settings" configuration object.Valentin Bartenev1-1/+1
It has the following structure and default values: { "http": { "header_read_timeout": 30, "body_read_timeout": 30, "send_timeout": 30, "idle_timeout": 180, "max_body_size": 8388608 } }
2018-07-09Router: increased HTTP connection related limits.Valentin Bartenev1-5/+5
2018-07-05PHP: fixed request body processing.Valentin Bartenev1-19/+3
The implementation of module was based on the assumption that PHP reads request body and headers in the particular order. For the POST request the body goes before headers and vice versa for all other requests. But as it appeared later, this order is unspecified and depends on many factors, including the particular code of PHP application. Among other factors those can affect ordering: - presence of "Content-Type" header; - "variables_order" php.ini setting; - "enable_post_data_reading" php.ini setting; - reading php://input by application; and this list can be incomplete. As a temporary workaround, request body now is always put before headers and it is gracefully skipped whenever PHP wants to get headers. This closes #144 issue on GitHub.
2018-06-25Introduced nxt_length() macro.Valentin Bartenev1-3/+3
2018-05-30Fixed keep-alive hanging after reconfiguration.Igor Sysoev1-60/+30
2018-04-27Eliminating possible NULL pointer dereference.Max Romanov1-1/+3
Found by Coverity (CID 276138).
2018-04-26Controller waits READY message from router.Max Romanov1-0/+34
This required to avoid racing condition when controller receive router port before router receives controller port.
2018-04-19Router: fixed race condition while access log reopening.Valentin Bartenev1-2/+21
In order to reopen access log, the router process creates a memory pool and allocates a buffer to send RPC message for the main process. Previously, the memory pool was destroyed when RPC response handler was called. It appeared, that the buffer completion handler could be not triggered by that time and still remained in a queue. Now the memory pool is destroyed only after both events are happen.
2018-04-18Added missing cleanup when nxt_port_socket_write() failed.Valentin Bartenev1-13/+39