Commit Graph

1591 Commits

Author SHA1 Message Date
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
Andrey Zelenkov 26fcb46137 Tests: added read_buffer_size option in http(). 2019-09-18 00:25:57 +03:00
Andrey Zelenkov 23215c839f Tests: head() method introduced. 2019-09-17 21:15:15 +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
Andrey Zelenkov b5394c3956 Tests: fixed features check. 2019-09-16 17:49:49 +03:00
Andrey Zelenkov 65ca2d7b19 Tests: refactored prerequisites model. 2019-09-14 14:44:35 +03:00
Andrey Zelenkov 962cdb6659 Tests: prepare_env() introduced. 2019-09-16 15:37:32 +03:00
Andrey Zelenkov 13ecbe333a Tests: style and minor fixes in java.py. 2019-09-16 15:37:32 +03:00
Andrey Zelenkov a5b9c9241e Tests: more comments. 2019-09-16 15:37:32 +03:00
Andrey Zelenkov 7152162886 Tests: set default "unsafe" value. 2019-09-16 15:37:32 +03:00
Andrei Belov 6f1f3b48b2 Packages: added explicit library path for Java on RPM based distros.
This helps to avoid using excessive strictness in RPATH of Java modules.
2019-09-16 13:28:06 +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
Andrey Zelenkov f10a8a03a1 Tests: Java websockets tests. 2019-09-05 15:30:09 +03:00
Max Romanov 2b8cab1e24 Java: introducing websocket support. 2019-09-05 15:27:32 +03:00
Andrey Zelenkov 3e23afb0d2 Tests: increased read_timeout for websockets tests. 2019-09-03 21:23:32 +03:00
Max Romanov daadc2e00b Making request state handler calls more consistent. 2019-09-02 18:27:08 +03:00
Andrey Zelenkov 1cfd329b3d Tests: fixed recv_bytes() in websockets.py. 2019-09-02 18:03:33 +03:00
Andrey Zelenkov 790b4f8f00 Tests: removed duplicate websocket tests. 2019-09-02 18:03:17 +03:00
Andrey Zelenkov 70e808040d Tests: prevented writing non-chopped frames to the closed socket. 2019-09-02 14:55:00 +03:00
Andrey Zelenkov cb36616132 Tests: prevented writing to the closed socket for websocket tests. 2019-08-30 16:59:35 +03:00
Andrey Zelenkov ccd6c0dc05 Tests: websockets style fixes. 2019-08-30 15:37:44 +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
Valentin Bartenev 1298824130 Version bump. 2019-08-26 18:06:03 +03:00
Andrei Belov 9b459d5d26 Added changes for 1.10.0-2 bugfix release. 2019-08-23 12:10:20 +03:00
Max Romanov 5d4426ed65 Installing libunit files for websocket support. 2019-08-23 01:19:57 +03:00
Andrey Zelenkov c47af243b0 Tests: removed keepalive_interval for websocket tests.
Also increased read_timeout in frame_read() for slow hosts.
2019-08-22 21:28:03 +03:00
Valentin Bartenev bc57d1d076 Added tag 1.10.0 for changeset cdbba3c3e376 2019-08-22 18:56:22 +03:00
Valentin Bartenev 19f59b221d Generated Dockerfiles for Unit 1.10.0. 2019-08-22 18:43:25 +03:00
Valentin Bartenev 700987c355 Fixed rebuilding of Dockerfiles. 2019-08-22 18:43:21 +03:00
Valentin Bartenev 0a106e3cbc Added version 1.10.0 CHANGES. 2019-08-22 18:43:02 +03:00
Andrey Zelenkov 72b56388b7 Tests: Node.js websockets tests tuned. 2019-08-22 18:28:23 +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
Andrey Zelenkov 9bbf54e23e Tests: Node.js websockets. 2019-08-22 15:33:41 +03:00
Andrey Zelenkov 08601bbbf0 Tests: "--unsafe" option introduced. 2019-08-22 15:26:15 +03:00
Andrey Zelenkov b4c09e2954 Tests: reverted rerun for Java tests in 5e429a7f133c.
Each testcase should also recompile to be recompiled.
So backed out for now.
2019-08-21 14:24:23 +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
Andrey Zelenkov 4d7576d323 Tests: print decoded strings in detailed mode, if possible. 2019-08-14 16:26:47 +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