Commit Graph

705 Commits

Author SHA1 Message Date
Valentin Bartenev
f2c0f2899a Refactored nxt_process_create() for more explicit pipe closing. 2019-09-26 16:03:02 +03:00
Valentin Bartenev
9c06bfdf2c Fixed descriptors leak on process creation.
The leak has been introduced in 325b315e48c4.
This closes #322 issue in GitHub.
2019-09-26 16:03:01 +03:00
Tiago Natel
93ead87810 Removed linux/sched.h include.
The <sched.h> is already included by nxt_unix.h.

This closes #314 PR on GitHub.
2019-09-20 13:08:04 +00:00
Tiago Natel
20628c74fa Releasing init struct in case of errors.
Found by Coverity (CID 349485).
2019-09-20 13:12:04 +00:00
Tiago Natel
7f389c814a Closing leaking file descriptor.
Found by Coverity (CID 349484).
2019-09-20 13:16:33 +00:00
Valentin Bartenev
514f34144a Static: returning 404 for Unix domain sockets.
It's now similar to how attempts to access other non-regular files are handled.
2019-09-24 15:33:42 +03:00
Sergey Kandaurov
c416933171 PHP: zeroing the whole file_handle structure.
Fixes segfaults with PHP 7.4.
2019-09-23 11:56:31 +00:00
Valentin Bartenev
5c50329f8e Fixed segfault if an inappropriate file system object is requested.
Found by Coverity (CID 349483).
2019-09-20 14:31:19 +03:00
Valentin Bartenev
08a8d1510d Basic support for serving static files. 2019-09-19 02:47:09 +03:00
Tiago de Bem Natel de Moura
c554941b4f Initial applications isolation support using Linux namespaces. 2019-09-19 15:25:23 +03:00
Max Romanov
6346e641ee Releasing WebSocket frame in case of buffer allocation failure.
Found by Coverity (CID 349456).
2019-09-19 16:28:03 +03:00
Max Romanov
1fac43eebe Fixing master process crash after failed fork.
This closes #312 issue on GitHub.
2019-09-18 22:45:30 +03:00
Max Romanov
ab40ce3757 Go: removing nxt_main.h usage.
One small step to Go modules support.
2019-09-18 18:31:29 +03:00
Max Romanov
a216b15e99 Fixing request release order to avoid crashes on exit.
Each request references the router process structure that owns all memory
maps.  The process structure has a reference counter; each request increases
the counter to lock the structure in memory until request processing ends.
Incoming and outgoing buffers reference memory maps that the process owns,
so the process structure should be released only when all buffers are
released to avoid invalid memory access and a crash.

This describes the libunit library mechanism used for application processes.

The background of this issue is as follows:

The issue was found on buildbot when the router crashed during Java
websocket tests.  The Java application receives a notification from the
master process; when the notification is processed, libunit deletes the
process structure from its process hash and decrements the use counter;
however, active websocket connections maintain their use counts on the
process structure.  After that, when the master process is stopping the
application, libunit releases active websocket connections.  At this point,
it's important to release the connections' memory buffers before the
corresponding process structure and all shared memory segments are released.
2019-09-18 18:31:22 +03:00
Max Romanov
84e4a6437f Go: do not store pointer to Go object.
To pass Go object references to C and back we use hack with casting to
unsafe and then to uintptr.  However, we should not store such references
because Go not guaratnee it will be available by the same address.
Introducing map with integer key helps to avoid dereference stored address.

This closes #253 and #309 issues on GitHub.
2019-09-18 18:31:14 +03:00
Max Romanov
4ea9ed309e Reducing number of warning messages.
One alert per failed allocation is enough.
2019-09-18 18:31:06 +03:00
Max Romanov
9bacd21405 Protecting context structures with mutex.
By design, Unit context is created for the thread which reads messages from
the router.  However, Go request handlers are called in a separate goroutine
that may be executed in a different thread.  To avoid a racing condition,
access to lists of free structures in the context should be serialized.  This
patch should fix random crashes in Go applications under high load.

This is related to #253 and #309 issues on GitHub.
2019-09-18 18:30:58 +03:00
Valentin Bartenev
ca01845d89 Configuration: added ability to modify object members with slashes.
Example:

  PUT/POST/DELETE /config/listeners/unix:%2Fpath%2Fto%2Fsocket

This follows a49ee872e83d.
2019-09-18 16:03:28 +03:00
Valentin Bartenev
6352c21a58 HTTP parser: fixed parsing of target after literal space character.
In theory, all space characters in request target must be encoded; however,
some clients may violate the specification.  For the sake of interoperability,
Unit supports unencoded space characters.

Previously, if there was a space character before the extension or arguments
parts, those parts weren't recognized.  Also, quoted symbols and complex
target weren't detected after a space character.
2019-09-17 18:40:21 +03:00
Valentin Bartenev
3b77e402a9 HTTP parser: removed unused "plus_in_target" flag. 2019-09-16 20:17:42 +03:00
Valentin Bartenev
56f4085b9d HTTP parser: removed unused "offset" field.
Thanks to 洪志道 (Hong Zhi Dao).
2019-09-16 20:17:42 +03:00
Valentin Bartenev
2fb7a1bfb9 HTTP parser: removed unused "exten_start" and "args_start" fields. 2019-09-16 20:17:42 +03:00
Valentin Bartenev
64be8717bd Configuration: added ability to access object members with slashes.
Now URI encoding can be used to escape "/" in the request path:

  GET /config/listeners/unix:%2Fpath%2Fto%2Fsocket/
2019-09-16 20:17:42 +03:00
Max Romanov
2a6af1d214 Added "extern" to nxt_http_fields_hash_proto to avoid link issues. 2019-09-09 17:39:24 +03:00
Max Romanov
2b8cab1e24 Java: introducing websocket support. 2019-09-05 15:27:32 +03:00
Max Romanov
daadc2e00b Making request state handler calls more consistent. 2019-09-02 18:27:08 +03:00
Max Romanov
7053a35a60 Fixed WebSocket implementation that was broken on some systems.
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-30 00:07:54 +03:00
Igor Sysoev
e2abfaf381 Adding body handler to nxt_http_request_header_send(). 2019-08-26 18:29:00 +03:00
Max Romanov
e291841b33 Node.js: introducing websocket support. 2019-08-20 16:32:05 +03:00
Max Romanov
e501c74ddc Introducing websocket support in router and libunit. 2019-08-20 16:31:53 +03:00
Max Romanov
686f5b1436 Changing the sequence of body send execution.
Request state ready_handler required for further websocket events processing.
It is not required for regular response transferring.
2019-08-16 14:55:18 +03:00
Max Romanov
29911538ea Improving response header fields processing.
Fields are filtered one by one before being added to fields list.
This avoids adding and then skipping connection-specific fields.
2019-08-16 00:56:38 +03:00
Max Romanov
caea9d3c07 Fixing multi-thread port write racing conditions. 2019-08-16 00:48:11 +03:00
Max Romanov
1b095ff417 Renaming supplemental request structures in router.
- 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-14 23:59:46 +03:00
Max Romanov
4bef4256c0 Java: implementing multipart message support.
This closes #265 issue on GitHub.
2019-08-14 15:24:41 +03:00
Valentin Bartenev
274260bd28 Router: allowed empty configurations.
Now it's possible to delete "listeners" and "applications" objects.

This closes #187 issue on GitHub.
2019-08-06 17:13:13 +03:00
Valentin Bartenev
7fd9444728 Node.js: returning "this" from writeHead() to allow chaining.
In Node.js version 11.10.0 and later, the writeHead() function returns "this".
2019-08-06 16:24:11 +03:00
Igor Sysoev
c7210eaa5a nxt_h1proto_t definition was moved to h1proto implementation. 2019-08-06 15:29:40 +03:00
Igor Sysoev
17bb22a4e4 Refactored HTTP protocol callback table. 2019-08-06 15:29:39 +03:00
Axel Duch
7785c96c1a Added routing based on request scheme.
Scheme matches exact string “http” or “https”.
2019-07-24 13:47:35 +03:00
Valentin Bartenev
242dc363ce Perl: propagated compile options from perl build.
Some Perl compile options affects ABI and not using them while compiling
our module resulted in non-working build.

Notably on 32-bit Debian 10, Perl is built with -D_FILE_OFFSET_BITS=64
and our module after being compiled without this option caused segmentation
faults in unexpected places.
2019-07-17 21:17:30 +03:00
Max Romanov
dcf46a63eb Exiting application process in case of pre_init stage error. 2019-07-17 16:57:43 +03:00
Max Romanov
aab235c4dc Java: fixing realpath error message. 2019-07-17 10:52:48 +03:00
Valentin Bartenev
ef89815f03 PHP: fixed script filename setting, broken after 2a71417d297f. 2019-07-16 17:58:48 +03:00
Max Romanov
cc578b2e63 PHP: added PATH_INFO support. 2019-07-05 21:10:01 +03:00
Valentin Bartenev
924165c90b PHP: improved response status code handling.
There's no reason to parse "http_status_line"; the PHP interpreter already
does this.  If the line contains a valid status code, it's assigned to
"http_response_code".

This also fixes invalid status line handling, where the nxt_int_parse()
function returned -1; it was cast to unsigned, yielding response code 65535.
2019-07-05 18:42:30 +03:00
Max Romanov
b1ee073707 PHP: removing excessive debug message. 2019-06-28 12:20:00 +03:00
Max Romanov
ce17fef73d Fixed application crash handling in router.
Before this fix, request in router may hang until timeout expired if
application crashed during request processing.
2019-06-28 12:19:54 +03:00
Max Romanov
9ea4be7e4e Fixing allocation alignment for port fragments.
All allocated blocks for lvlhash required to be aligned because lower
address bits used for various extra information.  Using unaligned blocks
may cause invalid memory aceess.

This was issue found on buildbot running large configuration tests.
2019-06-28 12:19:48 +03:00
Max Romanov
3ceec5f4d2 Java: adding Content-Type response header for static files. 2019-06-28 12:19:40 +03:00