Commit Graph

1331 Commits

Author SHA1 Message Date
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
Max Romanov
f16ae01b12 Python: app module callable name configuration.
Now it is possible to specify the name of the application callable using
optional parameter 'callable'.  Default value is 'application'.

This closes #290 issue on GitHub.
2020-09-18 13:41:58 +03:00
Igor Sysoev
6b9882fc14 Fixed segmentation fault during reconfiguration.
If idle connection was closed before h1proto had been allocated
then c->socket.data is NULL.  This happens if nxt_h1p_idle_response()
is called by nxt_h1p_idle_close().  However, h1p->conn_write_tail
is used only in nxt_h1p_request_send() that would not be called
after nxt_h1p_idle_response().

The bug was introduced in f237e8c553fd.
2020-09-18 13:20:06 +03:00
Igor Sysoev
6cfbf4ba79 Fixed segmentation fault during reconfiguration. 2020-09-18 13:20:05 +03:00
Igor Sysoev
09f4db1fc0 Fixed use-after-free error during reconfiguration.
An idle connection was not removed from idle connection list
if the connections detected that listening socket had been closed.
2020-09-18 13:20:02 +03:00
hongzhidao
806135f1c9 Router: fixed "pass" to upstreams.
Messed up return values in nxt_upstream_find() caused error in applying any
configuration with a valid "pass" value in router configuration pointing to
upstream.  That wasn't the case in "listeners" objects, where the return value
wasn't checked.

Also, it caused segfault in cases where the "pass" option was configured with
variables and resulting value was pointing to a non-existent upstream.

Added missing return checks as well to catch possible memory allocation errors.

The bug was introduced in d32bc428f46b.

This closes #472 issue on GitHub.
2020-08-28 00:53:36 -04:00
Tiago Natel de Moura
77ecb6ab49 Isolation: remove redundant macro. 2020-09-16 17:52:53 +01:00
Max Romanov
d5973fb557 Python: changed request headers format in router protocol.
The coming ASGI support requires raw HTTP headers format.  Headers grouping
and upcase code were moved to WSGI module.
2020-09-15 20:12:25 +03:00
Max Romanov
5163551ffe Hardening header names comparation for grouping. 2020-09-15 20:11:48 +03:00
Max Romanov
d94dac091f Python: split module initialization from WSGI implementation.
This is required for futher ASGI implementation.
2020-09-14 13:27:02 +03:00
Max Romanov
d483aa74e6 Python: source file moved to 'python' sub-directory.
No functional changes.  Get ready for an increase in file number.
2020-09-14 12:07:30 +03:00
Max Romanov
bd4ca6a057 Fixing WebSocket frame retain function.
Some of the pointers were not adjusted after frame's memory re-allocation.
Fortunately, this function was not used and the bug has no effect.
2020-09-10 12:16:32 +03:00
Igor Sysoev
22c88f0253 Upstream connection was not closed for short chunked response. 2020-09-07 15:21:14 +03:00
Valentin Bartenev
70c2a4645e Vars: added $host.
This closes #407 issue on GitHub.
2020-08-28 19:34:49 +03:00
Tiago Natel de Moura
b65a8636bb Isolation: added "automount" option.
Now it's possible to disable default bind mounts of
languages by setting:

  {
      "isolation": {
           "automount": {
               "language_deps": false
           }
     }
  }

In this case, the user is responsible to provide a "rootfs"
containing the language libraries and required files for
the application.
2020-08-25 15:25:51 +01:00
Tiago Natel de Moura
30a242aa3c PHP: added bind mounts for extensions directory. 2020-08-25 13:28:14 +01:00
Valentin Bartenev
dcfa92c161 Configuration: removed "reschedule_timeout" option.
It's not used since cbcd76704c90.

This option is a leftover from previous IPC between router and applications
processes.  It was never documented, though.

Thanks to 洪志道 (Hong Zhi Dao).
2020-08-21 20:50:04 +03:00
Tiago Natel de Moura
4ad8c5b898 Isolation: mount tmpfs by default. 2020-08-20 15:44:29 +01:00
Tiago Natel de Moura
a8a7eeb1fc Moved isolation related code to "nxt_isolation.c". 2020-08-20 15:22:58 +01:00
Valentin Bartenev
9bf6efc55a Configuration: improved error message of invalid listener address.
Thanks to 洪志道 (Hong Zhi Dao).
This closes #466 issue on GitHub.
2020-08-19 15:36:57 +03:00
Max Romanov
7ffc617ae8 Supporting platforms without sendfile() implementation.
This is a quick and dirty sendfile() replacement.

This closes #452 PR on GitHub.
2020-08-17 12:28:48 +03:00
Max Romanov
4ac7a6f55f Style: changing preprocessor directives.
Using #if directives instead of #ifdef the same way as in other places.
2020-08-17 12:28:40 +03:00
Max Romanov
b04b5ce430 Fixing router assertion in result of application prefork error.
Buffer for application prefork request allocated from temp conf mem_pool.
If error response from main process received before buffer completion handler,
temp conf mem_pool destroyed and router may crash in completion handler.

Assertion "src/nxt_buf.c:208 assertion failed: data == b->parent" triggered
when NXT_DEBUG_ALLOC enabled in configure.

This patch disables completion handler and memory allocated for buffer
released with memory pool.
2020-08-13 16:08:38 +03:00
Tiago Natel de Moura
b9ed3384cb Fixed error handling of prefork callback.
Previously, an error during the prefork phase triggered assert:

 src/nxt_port.c:27 assertion failed: port->pair[0] == -1

and resulted in exiting of the main process.

This could be easily reproduced by pushing a configuration with "rootfs",
when daemon is running without required permissions.
2020-08-13 12:25:52 +01:00
Valentin Bartenev
a58f224e26 Fixed typo in return value check.
Found by Coverity (CID 361277).
2020-08-13 03:45:54 +03:00
Valentin Bartenev
93146616cf Basic variables support. 2020-08-13 02:46:54 +03:00