summaryrefslogtreecommitdiffhomepage
path: root/src (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2020-04-16Using malloc/free for the http fields hash.Max Romanov9-52/+24
This is required due to lack of a graceful shutdown: there is a small gap between the runtime's memory pool release and router process's exit. Thus, a worker thread may start processing a request between these two operations, which may result in an http fields hash access and subsequent crash. To simplify issue reproduction, it makes sense to add a 2 sec sleep before exit() in nxt_runtime_exit().
2020-04-15Fixed memory leak occurring upon failure to accept a connection.Igor Sysoev2-12/+11
2020-04-15Fixed crash that occurs when idle connections are closed forcibly.Igor Sysoev3-35/+77
2020-04-15Disabled epoll error processing when socket events are inactive.Igor Sysoev1-0/+7
2020-04-14Completing chained shared memory buffers.Max Romanov1-3/+14
After 41331471eee7 completion handlers should complete next buffer in chain. Otherwise buffer memory may leak. Thanks to Peter Tkatchenko for reporing the issue and testing fixes.
2020-04-10Resolving a racing condition while adding ports on the app's side.Max Romanov4-12/+43
An earlier attempt (ad6265786871) to resolve this condition on the router's side added a new issue: the app could get a request before acquiring a port.
2020-04-08Controller: improved handling of unix domain control socket.Valentin Bartenev4-14/+89
One of the ways to detect Unit's startup and subsequent readiness to accept commands relies on waiting for the control socket file to be created. Earlier, it was unreliable due to a race condition between the client's connect() and the daemon's listen() calls after the socket's bind() call. Now, unix domain listening sockets are created with a nxt_listen_socket_create() call as follows: s = socket(); unlink("path/to/socket.tmp") bind(s, "path/to/socket.tmp"); listen(s); rename("path/to/socket.tmp", "path/to/socket"); This eliminates a time-lapse when the socket file is already created but nobody is listening on it yet, which therefore prevents the condition described above. Also, it allows reliably detecting whether the socket is being used or simply wasn't cleaned after the daemon stopped abruptly. A successful connection to the socket file means the daemon has been started; otherwise, the file can be overwritten.
2020-04-08Controller: fixed cleaning up of control socket file in some cases.Valentin Bartenev1-6/+20
Previously, the unix domain control socket file might have been left in the file system after a failed nxt_listen_socket_create() call.
2020-04-08Removed unused code related to testing of address binding.Valentin Bartenev7-31/+9
2020-04-08Controller: eliminated extra control socket's sockaddr copying.Valentin Bartenev1-11/+1
2020-04-08Node.js: fixing Server.listen() method.Max Romanov1-1/+11
This is required for Express framework compatibility. This closes #418 issue on GitHub.
2020-04-06Fixing 'find & add' racing condition in connected ports hash.Max Romanov4-32/+29
Missing error log messages added.
2020-04-01Fixed build with Clang 10, broken by 32578e837322.Valentin Bartenev1-1/+3
This silences the -Wimplicit-int-float-conversion warning.
2020-03-30Rational number support in upstream server weight.Igor Sysoev2-24/+38
2020-03-30Configuration: support for rational numbers.Valentin Bartenev8-170/+135
2020-03-30Fixing application process infinite loop.Max Romanov1-21/+28
Main process exiting before app process init may have caused hanging.
2020-03-30Handling change file message in libunit.Max Romanov1-0/+10
This is required for proper log file rotation action.
2020-03-30Attributing libunit logging function for arguments validation.Max Romanov4-10/+31
2020-03-21Implemented "location" option for "return" action.Valentin Bartenev5-2/+60
This allows to specify redirects: { "action": { "return": 301, "location": "https://www.example.com/" } }
2020-03-27Added nxt_is_complex_uri_encoded()/nxt_encode_complex_uri().Valentin Bartenev2-44/+158
2020-03-27Updated URI escaping table for better conformity with RFC 3986.Valentin Bartenev1-6/+4
Now '>', '<', '"', '^', '\', '}', '|', '{', and '`' are also escaped.
2020-03-27Implemented "return" action.Valentin Bartenev4-4/+95
The "return" action can be used to immediately generate a simple HTTP response with an arbitrary status: { "action": { "return": 404 } } This is especially useful for denying access to specific resources.
2020-03-27Initialization of the action object made more consistent.Valentin Bartenev1-3/+3
2020-03-25Configuration: fixed comments parsing.Valentin Bartenev1-1/+5
Unclosed multi-line comments and "/" at the end of JSON shouldn't be allowed.
2020-03-19Completing buffers immediatelyMax Romanov1-5/+2
This fixes crash introduced in 039b00e32e3d.
2020-03-19Completing request header buffers to avoid memory leak.Max Romanov3-22/+29
Before this fix, only persistent connection request buffers were completed. This issue was introduced in dc403927ab0b.
2020-03-17Fixing body fd access racing condition.Max Romanov2-16/+32
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 Romanov10-36/+441
This closes #386 on GitHub.
2020-03-12Moving request memory pool retain call after RPC data allocation.Max Romanov2-10/+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-12Checking Content-Length value right after header parse.Max Romanov2-6/+8
The check was moved from the request body read stage.
2020-03-12Python: implementing input readline and line iterator.Max Romanov1-2/+145
2020-03-12Introducing readline function in libunit.Max Romanov4-44/+53
Ruby and Java modules now use this function instead of own implementations.
2020-03-06Round robin upstream added.Igor Sysoev10-34/+653
2020-03-04Legacy upstream code removed.Igor Sysoev4-274/+0
2020-03-04Refactored nxt_http_action.Igor Sysoev3-21/+19
2020-03-11Fixed negative patterns combined with address rules.Axel Duch1-6/+40
2020-03-04PHP: fixed log format in alert.Tiago Natel de Moura1-1/+2
Found by Coverity: CID 354832 and CID 354833.
2020-03-04The kqueue EOF flag might be ignored on some conditions.Igor Sysoev1-2/+2
If kqueue reported both the EVFILT_READ and the EVFILT_WRITE events for the socket but only the former had the EV_EOF flag set, the flag was silently ignored.
2020-03-03Added a "fallback" option to be used with the "share" action.Valentin Bartenev4-23/+68
It allows proceeding to another action if a file isn't available. An example: { "share": "/data/www/", "fallback": { "pass": "applications/php" } } In the example above, an attempt is made first to serve a request with a file from the "/data/www/" directory. If there's no such file, the request is passed to the "php" application. Fallback actions may be nested: { "share": "/data/www/", "fallback": { "share": "/data/cache/", "fallback": { "proxy": "http://127.0.0.1:9000" } } }
2020-03-03Improved validation of the "action" object.Valentin Bartenev1-16/+41
Now it enforces the mutual exclusivity of "pass", "proxy", and "share" options.
2020-03-03PHP: optimization to avoid surplus chdir(2) calls.Tiago Natel de Moura1-99/+299
For each request, the worker calls the php_execute_script function from libphp that changes to the script directory before doing its work and then restores the process directory before returning. The chdir(2) calls it performs are unnecessary in Unit design. In simple benchmarks, profiling shows that the chdir syscall code path (syscall, FS walk, etc.) is where the CPU spends most of its time. PHP SAPI semantics requires the script to be run from the script directory. In Unit's PHP implementation, we have two use cases: - script - arbitrary path The "script" configuration doesn't have much need for a working directory change: it can be changed once at module initialization. The module needs to chdir again only if the user's PHP script also calls chdir to switch to another directory during execution. If "script" is not used in Unit configuration, we must ensure the script is run from its directory (thus calling chdir before exec), but there's no need to restore the working directory later. Our implementation disables mandatory chdir calls with the SAPI option SAPI_OPTION_NO_CHDIR, instead calling chdir only when needed. To detect the user's calls to chdir, a simple "unit" extension is added that hooks the built-in chdir() PHP call.
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-03-03Java: fixing Spring applications start.Max Romanov1-1/+1
This closes #403 issue on GitHub.
2020-03-03Node.js: fixing x86 warning about the signed/unsigned comparison.Max Romanov1-2/+1
2020-02-25PHP: fixed php >= 7.4 with zts enabled.Tiago Natel de Moura1-13/+17
2020-02-20Configuration: removing UTF-8 BOM from the input JSON.Valentin Bartenev1-0/+7
Some editors can add it to JSON files.
2020-02-20Configuration: stripping comments from the input JSON.Valentin Bartenev1-6/+66
This allows to have JavaScript-like comments in the uploading JSON.
2020-02-05Kept the value of c->socket.read_handler while data is available.Tiago Natel de Moura1-4/+0
This closes #370 in GitHub.
2020-02-04Removing duplicate macro definitions.Max Romanov1-4/+0
This issue was introduced in 2c7f79bf0a1f.
2020-02-03Initializing local buffer ctx_impl field for correct release.Max Romanov1-0/+1
Uninitialized ctx_impl field may cause crash in application process. To reproduce the issue, need to trigger shared memory buffer send error on application side. In our case, send error caused by router process crash. This issue was introduced in 2c7f79bf0a1f.