Commit Graph

1625 Commits

Author SHA1 Message Date
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
Andrei Zeliankou
df374057f7 Tests: $host varaible test.
Also added few tests for $uri and minor style fixes.
2020-08-31 03:14:02 +01: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
d1bdaf98ba Tests: disable of language_deps. 2020-08-25 15:27:51 +01: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
244ffb2829 Tests: PHP extension mounts. 2020-08-25 13:48:33 +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
10738c3fe2 Tests: default tmpfs in rootfs. 2020-08-20 15:53:20 +01: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
Valentin Bartenev
a13018fecb Version bump. 2020-08-17 11:57:55 +03:00
Valentin Bartenev
6473d4b65a Added tag 1.19.0 for changeset 86cdf66f8274 2020-08-13 19:22:57 +03:00
Valentin Bartenev
ba445d31f1 Generated Dockerfiles for Unit 1.19.0. 2020-08-13 19:22:41 +03:00
Valentin Bartenev
b8c7bc5a47 Added version 1.19.0 CHANGES. 2020-08-13 19:22:41 +03:00
Tiago Natel de Moura
479fdff39d Tests: set root by unprivilaged user. 2020-08-13 12:17:15 +01:00
Andrei Zeliankou
8032686a57 Tests: added test with error on loading application. 2020-08-13 13:17:27 +01:00
Andrei Zeliankou
c40e45344f Tests: added variables tests. 2020-08-13 13:17:01 +01: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
Remi Collet
21ac95f17e PHP: compatibility with 8.0.0 Beta 1.
This closes #441 PR on GitHub.
2020-08-12 22:55:01 +03:00
Max Romanov
09685e2b41 Responding with error in case of first process start failure.
After shared application port introducing, request queue in router was
removed and requests may stuck forever waiting for another process start.
2020-08-12 15:25:29 +03:00
Max Romanov
2136eb411c Fixing issues found by static analyzer. 2020-08-12 13:37:49 +03:00
Max Romanov
fd2c01c58f Fixing return value initialization. 2020-08-11 21:48:46 +03:00
Max Romanov
f147943f63 Style fixes for 2 file descriptors transfer over port.
Two consecutive fd and fd2 fields replaced with array.
2020-08-11 21:48:27 +03:00
Max Romanov
acb0cca49d Moving file descriptor blocking to libunit.
The default libunit behavior relies on blocking the recv() call for port file
descriptors, which an application may override if needed.  For external
applications, port file descriptors were toggled to blocking mode before the
exec() call.  If the exec() call failed, descriptor remained blocked, so the
process hanged while trying to read from it.

This patch moves file descriptor mode switch inside libunit.
2020-08-11 21:48:16 +03:00
Max Romanov
8cf522bf2d Wrapping close() call in libunit for logging. 2020-08-11 19:20:36 +03:00
Max Romanov
e227fc9e62 Introducing application and port shared memory queues.
The goal is to minimize the number of syscalls needed to deliver a message.
2020-08-11 19:20:34 +03:00
Max Romanov
a82cf4ffb6 Circular queues implementations and a test.
- naive circular queue, described in the article "A Scalable, Portable, and
 Memory-Efficient Lock-Free FIFO Queue" by Ruslan Nikolaev:
https://drops.dagstuhl.de/opus/volltexte/2019/11335/pdf/LIPIcs-DISC-2019-28.pdf
- circular queue, proposed by Valentin Bartenev in the "Unit router application
IPC" design draft
2020-08-11 19:20:32 +03:00
Max Romanov
a1e9df2aef Port message extended to transfer 2 file descriptors. 2020-08-11 19:20:30 +03:00
Max Romanov
72475ee11c Made router port message handlers into static functions.
Mostly harmless.
2020-08-11 19:20:28 +03:00
Max Romanov
496f41c134 Tests: reducing the number of generated applications.
Each application initializes a shared port with 2 file descriptors, so the test
fails because the router reaches the open files limit.
2020-08-11 19:20:25 +03:00
Max Romanov
bab4a9e9f2 Tests: skipping idle zero timeout.
This is a temporary solution after the 'shared port' patch.  The application
process becomes idle immediately after creation.  Even if it starts processing
a request (without acknowledging it yet), it is stopped by the router because
an 'out-of-idle-time' event occurs.
2020-08-11 19:20:23 +03:00
Max Romanov
f4a118f84a Adding debug messages to catch process management issues. 2020-08-11 19:20:20 +03:00
Max Romanov
2f3d27fa22 Process structures refactoring in runtime and libunit.
Generic process-to-process shared memory exchange is no more required.  Here,
it is transformed into a router-to-application pattern.  The outgoing shared
memory segments collection is now the property of the application structure.
The applications connect to the router only, and the process only needs to group
the ports.
2020-08-11 19:20:17 +03:00
Max Romanov
8359560612 Introducing the shared application port.
This is the port shared between all application processes which use it to pass
requests for processing.  Using it significantly simplifies the request
processing code in the router.  The drawback is 2 more file descriptors per each
configured application and more complex libunit message wait/read code.
2020-08-11 19:20:15 +03:00
Max Romanov
6e31d6cd39 Changing router to application shared memory exchange protocol.
The application process needs to request the shared memory segment from the
router instead of the latter pushing the segment before sending a request to
the application.  This is required to simplify the communication between the
router and the application and to prepare the router for using the application
shared port and then the queue.
2020-08-11 19:20:13 +03:00
Max Romanov
3cbc22a6dc Changing router to application port exchange protocol.
The application process needs to request the port from the router instead of the
latter pushing the port before sending a request to the application.  This is
required to simplify the communication between the router and the application
and to prepare the router to use the application shared port and then the queue.
2020-08-11 19:20:10 +03:00
Max Romanov
bf647588ff Adding a reference counter to the libunit port structure.
The goal is to minimize the number of (pid, id) to port hash lookups which
require a library mutex lock.  The response port is found once per request,
while the read port is initialized at startup.
2020-08-11 19:20:06 +03:00
Max Romanov
ec3389b63b Libunit refactoring: port management.
- Changed the port management callbacks to notifications, which e. g. avoids
the need to call the libunit function
- Added context and library instance reference counts for a safer resource
release
- Added the router main port initialization
2020-08-11 19:19:55 +03:00
Max Romanov
3a721e1d96 Fixing leaked configuration objects.
If there are no listen sockets, the router configuration usage counter
remains 0 and never decreases.  The only moment to release a configuration is
right after a configuration update.
2020-08-09 10:26:19 +03:00