Commit Graph

1106 Commits

Author SHA1 Message Date
Valentin Bartenev
cb28b41311 PHP: prevention of consuming unread request body on finalization.
The php_request_shutdown() function calls sapi_deactivate() that tries to read
request body into a dummy buffer.  In our case it's just waste of CPU cycles.

This change is also required for the following implementation of the
fastcgi_finish_request() function, where the request context can be
cleared by the time of finalization.
2020-11-11 12:09:49 +03:00
Max Romanov
896d8e8bfb Fixing multi-buffer body send to application.
Application shared queue only capable to pass one shared memory buffer.
The rest buffers in chain needs to be send directly to application in response
to REQ_HEADERS_AC message.

The issue can be reproduced for configurations where 'body_buffer_size' is
greater than memory segment size (10 Mb).  Requests with body size greater
than 10 Mb are just `stuck` e.g. not passed to application awaiting for more
data from router.

The bug was introduced in 1d84b9e4b459 (v1.19.0).
2020-11-10 22:27:08 +03:00
Max Romanov
5fd2933d2e Python: supporting ASGI legacy protocol.
Introducing manual protocol selection for 'universal' apps and frameworks.
2020-11-10 22:27:08 +03:00
Max Romanov
702e7bcc89 Java: fixing ClassGraph deprecated API call.
The issue (deprecated API warning) introduced by ClassGraph upgrade
in ccd5c695b739 commit.
2020-11-06 20:41:56 +03:00
Max Romanov
2220b8258f Ruby: error checking during thread creation.
Application terminates in case of thread creation failure.
2020-11-05 17:02:55 +03:00
Max Romanov
d321d454f9 Perl: request processing in multiple threads.
This closes #486 issue on GitHub.
2020-11-05 16:10:59 +03:00
Max Romanov
b6475df79c Ruby: request processing in multiple threads.
This closes #482 issue on GitHub.
2020-11-05 12:45:10 +03:00
Max Romanov
9f8b746e77 Ruby: reusing static constant references to string objects.
This shall save a couple of CPU cycles in request processing.
2020-11-05 12:45:08 +03:00
Max Romanov
29db46c52b Java: request processing in multiple threads.
This closes #458 issue on GitHub.
2020-11-05 00:06:10 +03:00
Max Romanov
8e37b1cbf5 Python: fixing some arguments reference counting. 2020-11-05 00:05:00 +03:00
Max Romanov
8dcb0b9987 Python: request processing in multiple threads.
This closes #459 issue on GitHub.
2020-11-05 00:04:59 +03:00
Max Romanov
4225361f0e Python: introducting macro to simplify minor version check. 2020-11-05 00:04:58 +03:00
Valentin Bartenev
d03b217f33 Fixed building test app without debug.
Compilers complained about unused variables after 37e2a3ea1bf1.
2020-11-01 13:22:11 +03:00
Max Romanov
bbe4b97ca1 Java: supporting jsp-file attribute for servlet.
This closes #487 issue on GitHub.
2020-10-30 17:33:36 +03:00
Valentin Bartenev
50af47fd7c Isolation: fixed passing custom options to nmount().
The "iov" array was filled incorrectly when custom mounting options were set.
2020-10-30 07:55:26 +03:00
Tiago Natel de Moura
0390cb3a61 Isolation: mounting of procfs by default when using "rootfs". 2020-10-29 20:30:53 +00:00
Tiago Natel de Moura
5ffd88ad7c Isolation: correctly unmount non-dependent paths first.
When mount points reside within other mount points, this
patch sorts them by path length and then unmounts then
in an order reverse to their mounting.  This results in
independent paths being unmounted first.

This fixes an issue in buildbots where dependent paths failed
to unmount, leading to the build script removing system-wide
language libraries.
2020-10-29 14:24:38 +00:00
Max Romanov
f007ad4dcf Added threading to the libunit test app. 2020-10-28 00:01:46 +03:00
Max Romanov
80a8cb835b Preserving the app port write socket.
The socket is required for intercontextual communication in multithreaded apps.
2020-10-28 00:01:46 +03:00
Max Romanov
d8cc830ea0 Libunit: waking another context with the RPC_READY message. 2020-10-28 00:01:46 +03:00
Max Romanov
4cb8aeb31a Router: introducing the PORT_ACK message.
The PORT_ACK message is the router's response to the application's NEW_PORT
message.  After receiving PORT_ACK, the application is safe to process requests
using this port.

This message avoids a racing condition when the application starts processing a
request from the shared queue and sends REQ_HEADERS_ACK.  The REQ_HEADERS_ACK
message contains the application port ID as reply_port, which the router uses
to send request data.  When the application creates a new port, it
immediately sends it to the main router thread.  Because the request is
processed outside the main thread, a racing condition can occur between the
receipt of the new port in the main thread and the receipt of REQ_HEADERS_ACK
in the worker router thread where the same port is specified as reply_port.
2020-10-28 00:01:46 +03:00
Max Romanov
131b6a7ffa Libunit: releasing cached read buffers when destroying context. 2020-10-28 00:01:46 +03:00
Max Romanov
a5508cec7a Libunit: added a function to discern main and worker contexts. 2020-10-28 00:01:46 +03:00
Max Romanov
28ab1de364 Libunit: gracefully quitting a multicontext application. 2020-10-28 00:01:46 +03:00
Max Romanov
ccee391ab2 Router: broadcasting the SHM_ACK message to all process ports. 2020-10-28 00:01:46 +03:00
Max Romanov
735bb2f127 Added error response logging.
Every internal server error response should have a clear description in log.
2020-10-28 00:01:46 +03:00
Max Romanov
38a9027fe5 Router: checking a buffer before accessing its memory fields.
This fixes the router's crash on buildbot; the reason was an unexpected 'last'
response from the application to the router arriving before the response
headers.  The last buffer is not a memory buffer, so the result of accessing
memory fields is unpredictable.

The unexpected 'last' message was caused by an error in libunit; fixed in
fee8fd855a00.
2020-10-28 00:01:46 +03:00
Max Romanov
00561a961f Libunit: protecting the new mmap from being used in another thread.
Until the mmap is received by the router, only the creator thread may use this
mmap, so the "mmap not found" state in the router is avoided.
2020-10-28 00:01:46 +03:00
Max Romanov
779b1131c5 Router: closing app worker's ports. 2020-10-28 00:01:46 +03:00
Valentin Bartenev
434c3228d9 Increased request memory pool size.
Previous value was too small, which reduced efficiency of the pool causing
a lot of additional allocations even for simple request and response.
2020-10-26 22:26:02 +03:00
Max Romanov
d8628a43d0 Fixing uninitialized ncpu value on unsupported platforms.
Thanks to @geyslan.

This closes #455 issue on GitHub.
2020-10-14 18:41:31 +03:00
Max Romanov
9dcb7ec4b7 Java: response locale methods implemented.
This closes #479 issue on GitHub.
2020-10-14 16:18:34 +03:00
Igor Sysoev
90b2c9f7d6 Using union instead of "void *". 2020-10-13 12:56:56 +03:00
Igor Sysoev
f541cbcce4 Using C99 style declaration. 2020-10-13 12:56:56 +03:00
Igor Sysoev
edafa954d4 Reordering declarations. 2020-10-13 12:56:56 +03:00
Valentin Bartenev
0919166145 Fixed building with Python 3.9.
PyUnicode_GET_SIZE() in deprecated since 3.3 and will be removed in 3.12.
In version 3.9 it was explicitly marked by deprecation warning causing
compilation error with Unit.

PyUnicode_GET_LENGTH() must be used instead.
2020-10-13 01:37:39 +03:00
Valentin Bartenev
2821b3347c PHP: compatibility with 8.0.0 RC1.
This closes #474 PR on GitHub.
2020-10-06 18:12:05 +03:00
Valentin Bartenev
3f513f434f Router: fixed "not empty" pattern matching.
The "!" pattern should be opposite to "", i.e. match only non-empty values.
But after 3c00af54b937 it was equal to "!*", which is wrong.
2020-10-07 20:06:30 +03:00
Max Romanov
703d79042b Removing a meaningless warning message.
Data in the queue and the socket are transmitted independently; special
READ_QUEUE and READ_SOCKET message types are used for synchronization.

The warning was accidentally committed with changeset 1d84b9e4b459.
2020-10-06 19:06:33 +03:00
Igor Sysoev
9d8d2c1758 Fixed comment.
Thanks to 洪志道 (Hong Zhi Dao).
2020-10-02 15:16:09 +03:00
Max Romanov
c4c2f90c5b Python: ASGI server introduced.
This closes #461 issue on GitHub.
2020-10-01 23:55:23 +03:00
Max Romanov
bbc6d2470a Publishing libunit's malloc() and free() wrappers for apps. 2020-10-01 23:55:10 +03:00
Tiago Natel de Moura
c2eb245b32 PHP: fixed "rootfs" isolation dependency on system mounts. 2020-09-09 19:28:44 +01:00
Max Romanov
c5cb2432c4 Fixing router connection pool leakage.
The connection's local socket address is allocated from the connection
pool before the request is passed to the application; however, with keep-alive
connections, this field was unconditionally reset by a socket configuration
value that could be NULL.  For the next request, the address was allocated
again from the same connection pool.  Nonetheless, all leaked addresses
were released when the connection was closed.

The issue introduced in changeset 5c7dd85fabd5.
2020-09-30 16:36:57 +03:00
Max Romanov
153e8a8779 Fixing leakage caused by incorrect in_hash flag cleanup.
Large-bodied requests are added to the request hash to be found when the body
arrives.  However, changeset 1d84b9e4b459 introduced a bug: the 'in_hash' flag,
used to remove the request from the hash at request release, was cleared after
the first successful request lookup.  As a result, the entry was never removed.
2020-09-30 01:17:09 +03:00
Valentin Bartenev
67d33fac66 MIME: added AVIF and APNG image formats.
AVIF is a modern image format based on the AV1 video codec.  It generally has
better compression than other widely used formats (WebP, JPEG, PNG, and GIF)
and is designed to supersede them.  Support was already added to the latest
version of Chrome.

APNG extends PNG to permit animated images that work similarly to animated GIF.
It's supported by most modern browsers.

Also removed duplicated ".svg" entry.
2020-09-29 23:23:32 +03:00
Max Romanov
61eba6eef1 Wrapping libunit's malloc() and free() calls for logging purposes.
This change aids heap usage analysis in applications.
The alloc and free functions are also required for lvlhash due to the upcoming
threading support, because using main nxt_memalign() and nxt_free() isn't safe
in a multithreaded app environment.  The reason is that these functions may use
thread-local structures which aren't initialized properly in applications.
2020-09-29 22:58:04 +03:00
Max Romanov
c721a5378d Fixing request buffer memory leakage in router.
The issue was introduced in changeset 1d84b9e4b459.  The request buffer was
transferred via the shared application queue, but the buffer position and the
'sent' flag were not updated after the buffer had been sent.
2020-09-29 22:57:56 +03:00
Max Romanov
c4b000f9cc Supporting HTTP/1.0 keep-alive.
The Apache HTTP server benchmarking tool, ab, issues HTTP/1.0 requests with
the 'Connection: Keep-Alive' header and expects a 'Connection: Keep-Alive'
header in the response.
2020-09-29 22:57:46 +03:00
Artem Konev
8ee96c224a Updated racially charged language in messages and comments. 2020-09-18 11:46:15 +01:00