summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-07-28Configuration: fixed buffer over-read in pattern validation.Axel Duch1-2/+3
There was an undefined behavior in the validation function, caused by testing one character after the string if a wildcard was at the end.
2020-07-25Using plain shared memory for configuration pass.Max Romanov4-83/+152
There is no restrictions on configration size and using segmented shared memory only doubles memory usage because to parse configration on router side, it needs to be 'plain' e. g. located in single continous memory buffer.
2020-07-24Configuration: added checking for presence of mandatory fields.Valentin Bartenev3-13/+131
2020-07-24Added missing ending indicator in object members validation lists.Valentin Bartenev1-1/+5
This fixes undefined behaviour due to array over-read if an unknown parameter is specified in an uidmap, a gidmap, or a php target object.
2020-07-24Configuration: removing redundant check.Axel Duch1-3/+3
Thanks to 洪志道 (Hong Zhi Dao).
2020-07-24Minor changes and renaming an NJS artifact to NXT.Axel Duch1-3/+3
This is partially related to #434 issue on Github. Thanks to 洪志道 (Hong Zhi Dao).
2020-07-23Fixing request_app_link reference counting.Max Romanov1-4/+2
Racing conditions reproduced periodically on test_python_process_switch.
2020-07-23Fixing various router crashes on exit caused by runtime pool free.Max Romanov1-7/+18
Currently, the router exits without waiting for the worker threads to stop. There is a short gap between the runtime memory pool's free and the exit, during which a worker thread may try to access a runtime structure. In turn, this may cause a crash. For now, it is better to keep this memory allocated.
2020-07-23PHP: using nxt_unit_default_init() for module structure init.Max Romanov1-32/+4
Using this function in all language modules helps to avoid code duplication and reduce the size of future patches.
2020-07-23Fixing main and application port structs file descriptor init.Max Romanov1-0/+2
Correct value for non-initialized file descriptor is -1, because most of the checks in libunit compares file descriptor with -1 before performing an action. Using 0 as default value, may cause to close file descriptor #0, this may affect application logic. It is not required to list this patch in changelog because impact is not seen by end users.
2020-07-23PHP: removing assertion to fix build on macOS.Max Romanov1-1/+5
The nxt_assert macro uses nxt_thread_context, which caused the following linker error when using it in the library: ld: illegal thread local variable reference to regular symbol _nxt_thread_context for architecture x86_64
2020-07-22Fixing buffer overflow check in discovery.Max Romanov1-1/+1
Incorrect check prevents Unit to start without modules. This issue was introduced in 4a3ec07f4b19.
2020-07-21PHP: logging in request context when possible.Valentin Bartenev1-2/+12
2020-07-21PHP: fixed incorrect time in interpreter error log messages.Valentin Bartenev1-5/+6
Previously, the log message callback used a generic log function, that relied on the process time cache. Since there were no time update calls in the application processes, all log lines were printed with the same time, usually correlated with the process start. Now, a non-cached logging function from libunit is used.
2020-07-21Fixed non-debug log time format in libunit.Valentin Bartenev1-0/+7
This makes log format used in libunit consistent with the daemon, where milliseconds are printed only in the debug log level. Currently a compile time switch is used, since there's no support for runtime changing of a log level for now. But in the future this should be a runtime condition, similar to nxt_log_time_handler().
2020-07-10Router: route patterns multi wildcards fix.Axel Duch1-3/+6
Matching 'start' and 'end' position now adjusted to avoid false matching. This is related to #434 issue on Github. Thanks to 洪志道 (Hong Zhi Dao).
2020-07-06Destroying temporary router configuration.Igor Sysoev2-34/+40
The lifespan of a listening socket is longer than both router configuration's and temporary router configuration's lifespan, so the sockets should be stored in persistent queues. Safety is ensured by the fact that the router processes only one new configuration at any time.
2020-07-04Router: route patterns multi wildcards support.Axel Duch2-152/+210
2020-06-23Upstream chunked transfer encoding support.Igor Sysoev6-97/+178
2020-06-23Decreased level of some socket close() errors.Igor Sysoev2-13/+36
2020-06-23Isolation: fixed build when features aren't detected.Tiago Natel de Moura4-111/+114
2020-05-28Added "rootfs" feature.Tiago Natel de Moura22-71/+1285
2020-03-09Refactor of process management.Tiago Natel de Moura26-1330/+1541
The process abstraction has changed to: setup(task, process) start(task, process_data) prefork(task, process, mp) The prefork() occurs in the main process right before fork. The file src/nxt_main_process.c is completely free of process specific logic. The creation of a process now supports a PROCESS_CREATED state. The The setup() function of each process can set its state to either created or ready. If created, a MSG_PROCESS_CREATED is sent to main process, where external setup can be done (required for rootfs under container). The core processes (discovery, controller and router) doesn't need external setup, then they all proceeds to their start() function straight away. In the case of applications, the load of the module happens at the process setup() time and The module's init() function has changed to be the start() of the process. The module API has changed to: setup(task, process, conf) start(task, data) As a direct benefit of the PROCESS_CREATED message, the clone(2) of processes using pid namespaces now doesn't need to create a pipe to make the child block until parent setup uid/gid mappings nor it needs to receive the child pid.
2020-05-28Moving nxt_stream_ident to shared memory.Max Romanov3-3/+31
This aims to avoid stream id clashes after router restart.
2020-05-28Added NULL check for engine->port.Max Romanov1-2/+4
This is required to handle REMOVE_PID messages if router engine initialization is incomplete.
2020-05-28Closing unsent file descriptors from port queue.Max Romanov1-0/+6
After a process exits, all ports linked to it from other processes should be closed. All unsent file descriptors in port queue, marked as "close after send", should be closed to avoid resource leakage.
2020-05-20Static: fixed potential undefined behavior in memcpy().Valentin Bartenev1-1/+1
According to the C standard, pointer arguments passed to memcpy() calls shall still have valid values. NULL is considered as invalid. Found with GCC Static Analyzer.
2020-05-20PHP: building with PHP 8 (development version).Remi Collet1-0/+8
2020-05-15Fixed global constant declaration (appeared in 9af10e099d09).Valentin Bartenev1-1/+1
This fixes building with GCC 10, which is default to -fno-common. See: https://gcc.gnu.org/gcc-10/porting_to.html
2020-05-15Router: removed two unused assignments.Valentin Bartenev2-5/+2
This should resolve some static analyzers warnings.
2020-05-14Router: decode uri and args.Axel Duch4-60/+381
2020-05-14PHP: implemented "targets" option.Valentin Bartenev11-260/+509
This allows to specify multiple subsequent targets inside PHP applications. For example: { "listeners": { "*:80": { "pass": "routes" } }, "routes": [ { "match": { "uri": "/info" }, "action": { "pass": "applications/my_app/phpinfo" } }, { "match": { "uri": "/hello" }, "action": { "pass": "applications/my_app/hello" } }, { "action": { "pass": "applications/my_app/rest" } } ], "applications": { "my_app": { "type": "php", "targets": { "phpinfo": { "script": "phpinfo.php", "root": "/www/data/admin", }, "hello": { "script": "hello.php", "root": "/www/data/test", }, "rest": { "root": "/www/data/example.com", "index": "index.php" }, } } } }
2020-05-14Configuration: URI encoding in the "pass" option.Valentin Bartenev4-65/+119
This is useful to escape "/" in path fragments. For example, in order to reference the application named "foo/bar": { "pass": "applications/foo%2Fbar" }
2020-05-12Waiting for router instead of reporting to user on config update.Max Romanov1-24/+25
2020-05-12Blocking config change when applying the initial router config.Max Romanov1-11/+32
2020-04-16Using malloc/free for the http fields hash.Max Romanov9-52/+24
This is required due to lack of a graceful shutdown: there is a small gap between the runtime's memory pool release and router process's exit. Thus, a worker thread may start processing a request between these two operations, which may result in an http fields hash access and subsequent crash. To simplify issue reproduction, it makes sense to add a 2 sec sleep before exit() in nxt_runtime_exit().
2020-04-15Fixed memory leak occurring upon failure to accept a connection.Igor Sysoev2-12/+11
2020-04-15Fixed crash that occurs when idle connections are closed forcibly.Igor Sysoev3-35/+77
2020-04-15Disabled epoll error processing when socket events are inactive.Igor Sysoev1-0/+7
2020-04-14Completing chained shared memory buffers.Max Romanov1-3/+14
After 41331471eee7 completion handlers should complete next buffer in chain. Otherwise buffer memory may leak. Thanks to Peter Tkatchenko for reporing the issue and testing fixes.
2020-04-10Resolving a racing condition while adding ports on the app's side.Max Romanov4-12/+43
An earlier attempt (ad6265786871) to resolve this condition on the router's side added a new issue: the app could get a request before acquiring a port.
2020-04-08Controller: improved handling of unix domain control socket.Valentin Bartenev4-14/+89
One of the ways to detect Unit's startup and subsequent readiness to accept commands relies on waiting for the control socket file to be created. Earlier, it was unreliable due to a race condition between the client's connect() and the daemon's listen() calls after the socket's bind() call. Now, unix domain listening sockets are created with a nxt_listen_socket_create() call as follows: s = socket(); unlink("path/to/socket.tmp") bind(s, "path/to/socket.tmp"); listen(s); rename("path/to/socket.tmp", "path/to/socket"); This eliminates a time-lapse when the socket file is already created but nobody is listening on it yet, which therefore prevents the condition described above. Also, it allows reliably detecting whether the socket is being used or simply wasn't cleaned after the daemon stopped abruptly. A successful connection to the socket file means the daemon has been started; otherwise, the file can be overwritten.
2020-04-08Controller: fixed cleaning up of control socket file in some cases.Valentin Bartenev1-6/+20
Previously, the unix domain control socket file might have been left in the file system after a failed nxt_listen_socket_create() call.
2020-04-08Removed unused code related to testing of address binding.Valentin Bartenev7-31/+9
2020-04-08Controller: eliminated extra control socket's sockaddr copying.Valentin Bartenev1-11/+1
2020-04-08Node.js: fixing Server.listen() method.Max Romanov1-1/+11
This is required for Express framework compatibility. This closes #418 issue on GitHub.
2020-04-06Fixing 'find & add' racing condition in connected ports hash.Max Romanov4-32/+29
Missing error log messages added.
2020-04-01Fixed build with Clang 10, broken by 32578e837322.Valentin Bartenev1-1/+3
This silences the -Wimplicit-int-float-conversion warning.
2020-03-30Rational number support in upstream server weight.Igor Sysoev2-24/+38
2020-03-30Configuration: support for rational numbers.Valentin Bartenev8-170/+135