Commit Graph

73 Commits

Author SHA1 Message Date
Max Romanov
64db3ef1bb Fixing prototype process crash.
A prototype stores linked application processes structures.  When an
application process terminates, it's removed from the list.  To avoid double
removal, the pointer to the next element should be set to NULL.

The issue was introduced in c8790d2a89bb.
2021-12-01 18:05:50 +03:00
Max Romanov
2c636a03f3 Sending shared port to application prototype.
Application process started with shared port (and queue) already configured.
But still waits for PORT_ACK message from router to start request processing
(so-called "ready state").

Waiting for router confirmation is necessary.  Otherwise, the application may
produce response and send it to router before the router have the information
about the application process.  This is a subject of further optimizations.
2021-11-24 13:11:47 +03:00
Tiago Natel de Moura
e207415a78 Introducing application prototype processes. 2021-11-09 15:48:44 +03:00
Valentin Bartenev
b6f4b3afb1 Improved logging of app module load errors. 2021-11-02 17:34:23 +03:00
Max Romanov
bba97134e9 Moving request limit control to libunit.
Introducting application graceful stop.  For now only used when application
process reach request limit value.

This closes #585 issue on GitHub.
2021-10-28 17:46:54 +03:00
Tiago Natel de Moura
0390cb3a61 Isolation: mounting of procfs by default when using "rootfs". 2020-10-29 20:30:53 +00:00
Max Romanov
80a8cb835b Preserving the app port write socket.
The socket is required for intercontextual communication in multithreaded apps.
2020-10-28 00:01:46 +03:00
Tiago Natel de Moura
a8a7eeb1fc Moved isolation related code to "nxt_isolation.c". 2020-08-20 15:22:58 +01: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
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
137c1e736f Fixing main and application port structs file descriptor init.
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-23 14:24:55 +03:00
Max Romanov
ef71948196 Fixing buffer overflow check in discovery.
Incorrect check prevents Unit to start without modules.

This issue was introduced in 4a3ec07f4b19.
2020-07-22 10:04:57 +03:00
Tiago Natel de Moura
f8ba5d6c00 Isolation: fixed build when features aren't detected. 2020-06-23 12:11:27 +01:00
Tiago Natel de Moura
e2b53e16c6 Added "rootfs" feature. 2020-05-28 14:57:41 +01:00
Tiago Natel de Moura
e9e5ddd5a5 Refactor of process management.
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-03-09 16:28:25 +00:00
Max Romanov
2dbfd7c35e Fixing process crash in case of module load error.
This is related to #330 issue on GitHub.
2019-10-22 16:14:02 +03:00
Max Romanov
dcf46a63eb Exiting application process in case of pre_init stage error. 2019-07-17 16:57:43 +03:00
Alexander Borisov
dccb4cf354 Removed unnecessary abstraction layer. 2019-03-06 15:26:45 +03:00
Max Romanov
5bfdebb9e4 Introducing Java Servlet Container beta. 2019-02-28 18:02:42 +03:00
Valentin Bartenev
029c1a9f50 Renamed "go" application type to "external".
There's nothing specific to Go language.  This type of application object can
be used to run any external application that utilizes libunit API.
2018-10-09 17:53:31 +03:00
Max Romanov
1bb22d1e92 Unit application library.
Library now used in all language modules.
Old 'nxt_app_*' code removed.

See src/test/nxt_unit_app_test.c for usage sample.
2018-08-06 17:27:33 +03:00
Max Romanov
4d818a6f23 Enabled body buffer shared memory segmentation.
Changeset #699 fixes shared memory allocation: continous buffer with
requested size should be allocated or function failed.  For body longer
than 10 Mb, this allocation will definitely fails.

For body buffer it is not required to send it in a single continous buffer,
so, need to request minimum reasonable amount of shared memory and try to
extend it, if possible or allocate next buffer.
2018-07-12 16:06:36 +03:00
Valentin Bartenev
1a52d876f7 Introduced nxt_length() macro. 2018-06-25 16:51:47 +03:00
Valentin Bartenev
d7e6e2bd8c Configuration of environment variables for application processes. 2018-05-28 20:55:23 +03:00
Valentin Bartenev
3e8dbfe5ff Added SERVER_SOFTWARE request meta-variable. 2018-05-21 16:14:24 +03:00
Valentin Bartenev
5371891492 Fixed segfault when two modules have the same type and version.
The bug appeared in 217e48a3b091.
This closes #104 issue on GitHub.
2018-04-20 23:57:46 +03:00
Valentin Bartenev
ab4f867996 Added missing checks if nxt_port_rpc_register_handler() failed.
This closes #97 issue on GitHub.
Thanks to 洪志道 (Hong Zhi Dao).
2018-04-17 21:13:43 +03:00
Max Romanov
2f3b9d4583 Handling error return from application 'run()' function.
Server error response generated or connection closed.
2018-04-05 17:20:26 +03:00
Alexander Borisov
49bd3a21e0 Changed version processing for modules. 2018-04-04 18:53:39 +03:00
Alexander Borisov
37051b6c15 Added Ruby support. 2018-03-21 16:50:07 +03:00
Valentin Bartenev
912a49c609 Reduced number of critical log levels. 2018-03-05 17:32:50 +03:00
Valentin Bartenev
27b00629e1 Fixed race condition while discovering modules.
Previously, the discovery process might exit before the main process
received a list of available modules.
2018-02-14 16:33:35 +03:00
Alexander Borisov
960962ddce Added Perl support. 2018-01-31 15:47:00 +03:00
Sergey Kandaurov
771e9d3cc3 Fixed formatting in nxt_sprintf() and logging. 2018-01-24 15:16:33 +03:00
Sergey Kandaurov
67c64a99fb Using size_t for the field width type of the "%*s" specifier. 2018-01-24 15:16:32 +03:00
Igor Sysoev
dbd7540a04 Removed duplicate declaration. 2017-12-28 20:50:49 +03:00
Igor Sysoev
9a6d3c5775 HTTP keep-alive connections support. 2017-12-28 16:01:06 +03:00
Igor Sysoev
497faf1b9a Changed nxt_mp_retain() and nxt_mp_release() interfaces. 2017-12-28 16:01:06 +03:00
Max Romanov
89c0f7c5db Implementing the ability to cancel request before worker starts processing it. 2017-12-27 17:46:17 +03:00
Max Romanov
be36cf52c8 Introducing application 'atexit' hook.
Finalizing Python interpreter.

This closes #65 issue on GitHub.
2017-12-27 14:02:11 +03:00
Valentin Bartenev
8830d73261 HTTP parser: reworked header fields handling. 2017-12-25 17:04:22 +03:00
Valentin Bartenev
4be9774540 Fixed protocol version string handling in router. 2017-12-07 17:02:05 +03:00
Igor Sysoev
3c6edead25 Added the debug option to module compatibility vector. 2017-10-18 18:05:51 +03:00
Valentin Bartenev
e4bea2c75c Optimized application type handling. 2017-10-10 19:15:08 +03:00
Valentin Bartenev
096562c0b1 Improved applications versions handling. 2017-10-05 16:46:18 +03:00
Max Romanov
730f5a9dd9 Using request mem pool for req<->app link.
Request <-> application link structure (nxt_req_app_link_t) used to register
the request in application request queue (nxt_app_t.requests) and generate
application-specific port message.

Now it is allocated from request pool.  This pool created for request parsing
and used to allocate and store information specific to this request.
2017-10-04 15:00:35 +03:00
Valentin Bartenev
75a6325656 Fixed memory leak caused by mempool related to request context.
The previous attempt of fixing this in e5a65b58101f hasn't been really
successful, because the actual memory leak was caused not by the request
parse context itself, but its memory pool.
2017-09-16 05:36:06 +03:00
Max Romanov
1449e27cb4 Fixing memory leak of request parse context. 2017-09-15 20:30:29 +03:00
Igor Sysoev
58907888e5 Style fixes. 2017-09-06 02:30:55 +03:00
Max Romanov
c937b8434a Double connection close attempt fix. 2017-09-05 10:22:46 -07:00