History log of /unit/src/nxt_main_process.c (Results 1 – 25 of 94)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 2240:0c49318572c2 13-Sep-2022 OutOfFocus4

Removed dead code.

Signed-off-by: Alejandro Colomar <alx@nginx.com>


Revision tags: 1.28.0-1, 1.28.0
# 2179:8686f63a2228 28-Jul-2022 Alejandro Colomar

Fixed support for abstract Unix sockets.

Unix domain sockets are normally backed by files in the
filesystem. This has historically been problematic when closing
and opening again such sockets, sinc

Fixed support for abstract Unix sockets.

Unix domain sockets are normally backed by files in the
filesystem. This has historically been problematic when closing
and opening again such sockets, since SO_REUSEADDR is ignored for
Unix sockets (POSIX left the behavior of SO_REUSEADDR as
implementation-defined, and most --if not all-- implementations
decided to just ignore this flag).

Many solutions are available for this problem, but all of them
have important caveats:

- unlink(2) the file when it's not needed anymore.

This is not easy, because the process that controls the fd may
not be the same process that created the file, and may not have
file permissions to remove it.

Further solutions can be applied to that caveat:

- unlink(2) the file right after creation.

This will remove the pathname from the filesystem without
closing the socket (it will continue to live until the last fd
is closed). This is not useful for us, since we need the
pathname of the socket as its interface.

- chown(2) or chmod(2) the directory that contains the socket.

For removing a file from the filesystem, a process needs
write permissions in the containing directory. We could
put sockets in dummy directories that can be chown(2)ed to
nobody. This could be dangerous, though, as we don't control
the socket names. It is our users who configure the socket
name in their configuration, and so it's easy that they don't
understand the many implications of not chosing an appropriate
socket pathname. A user could unknowingly put the socket in a
directory that is not supposed to be owned by user nobody, and
if we blindly chown(2) or chmod(2) the directory, we could be
creating a big security hole.

- Ask the main process to remove the socket.

This would require a very complex communication mechanism with
the main process, which is not impossible, but let's avoid it
if there are simpler solutions.

- Give the child process the CAP_DAC_OVERRIDE capability.

That is one of the most powerful capabilities. A process with
that capability can be considered root for most practical
aspects. Even if the capability is disabled for most of the
lifetime of the process, there's a slight chance that a
malicious actor could activate it and then easily do serious
damage to the system.

- unlink(2) the file right before calling bind(2).

This is dangerous because another process (for example, another
running instance of unitd(8)), could be using the socket, and
removing the pathname from the filesystem would be problematic.
To do this correctly, a lot of checks should be added before the
actual unlink(2), which is error-prone, and difficult to do
correctly, and atomically.

- Use abstract-namespace Unix domain sockets.

This is the simplest solution, as it only requires accepting a
slightly different syntax (basically a @ prefix) for the socket
name, to transform it into a string starting with a null byte
('\0') that the kernel can understand. The patch is minimal.

Since abstract sockets live in an abstract namespace, they don't
create files in the filesystem, so there's no need to remove
them later. The kernel removes the name when the last fd to it
has been closed.

One caveat is that only Linux currently supports this kind of
Unix sockets. Of course, a solution to that could be to ask
other kernels to implement such a feature.

Another caveat is that filesystem permissions can't be used to
control access to the socket file (since, of course, there's no
file). Anyone knowing the socket name can access to it. The
only method to control access to it is by using
network_namespaces(7). Since in unitd(8) we're using 0666 file
sockets, abstract sockets should be no more insecure than that
(anyone can already read/write to the listener sockets).

- Ask the kernel to implement a simpler way to unlink(2) socket
files when they are not needed anymore. I've suggested that to
the <linux-fsdevel@vger.kernel.org> mailing list, in:
<lore.kernel.org/linux-fsdevel/0bc5f919-bcfd-8fd0-a16b-9f060088158a@gmail.com/T>

In this commit, I decided to go for the easiest/simplest solution,
which is abstract sockets. In fact, we already had partial
support. This commit only fixes some small bug in the existing
code so that abstract Unix sockets work:

- Don't chmod(2) the socket if it's an abstract one.

This fixes the creation of abstract sockets, but doesn't make them
usable, since we produce them with a trailing '\0' in their name.
That will be fixed in the following commit.

This closes #669 issue on GitHub.

show more ...


Revision tags: 1.27.0-1, 1.27.0
# 2078:0996dd223cdd 18-Dec-2021 Alejandro Colomar

Fixed indentation.

Some lines (incorrectly) had an indentation of 3 or 5, or 7 or 9,
or 11 or 13, or 15 or 17 spaces instead of 4, 8, 12, or 16. Fix them.

Found with:

$ find src -type f | xargs g

Fixed indentation.

Some lines (incorrectly) had an indentation of 3 or 5, or 7 or 9,
or 11 or 13, or 15 or 17 spaces instead of 4, 8, 12, or 16. Fix them.

Found with:

$ find src -type f | xargs grep -n '^ [^ ]';
$ find src -type f | xargs grep -n '^ [^ *]';
$ find src -type f | xargs grep -n '^ [^ ]';
$ find src -type f | xargs grep -n '^ [^ *]';
$ find src -type f | xargs grep -n '^ [^ +]';
$ find src -type f | xargs grep -n '^ [^ *+]';
$ find src -type f | xargs grep -n '^ [^ +]';
$ find src -type f | xargs grep -n '^ [^ *+]';

show more ...


# 2050:d1298cc3f385 03-Dec-2021 Valentin Bartenev

Merged with the 1.26 branch.


Revision tags: 1.26.1-1, 1.26.1
# 2016:730e903f4534 24-Nov-2021 Max Romanov

Fixing zombie process appearance and hang up on shutdown.

After the c8790d2a89bb commit, the SIGCHLD handler may return before processing
all awaiting PIDs. To avoid zombie processes and ensure suc

Fixing zombie process appearance and hang up on shutdown.

After the c8790d2a89bb commit, the SIGCHLD handler may return before processing
all awaiting PIDs. To avoid zombie processes and ensure successful main
process termination, waitpid() must be called until an error is returned.

This closes #600 issue on GitHub.

show more ...


# 2014:f8a0992944df 24-Nov-2021 Max Romanov

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 processin

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.

show more ...


Revision tags: 1.26.0-1, 1.26.0
# 1998:c8790d2a89bb 09-Nov-2021 Tiago Natel de Moura

Introducing application prototype processes.


# 1997:a8a3f1d243ee 09-Nov-2021 Tiago Natel de Moura

Changed nxt_process_* for reuse.

This enables the reuse of process creation functions.


# 1996:35873fa78fed 09-Nov-2021 Tiago Natel de Moura

Introduced SCM_CREDENTIALS / SCM_CREDS in the socket control msgs.


# 1980:43553aa72111 28-Oct-2021 Max Romanov

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.


# 1970:06f77fc5a479 12-Oct-2021 Zhidao HONG

Removed unused declarations.

Declarations became unused after 6976d36be926.

No functional changes.


# 1969:be6409cdb028 09-Oct-2021 Zhidao HONG

Configuration: automatic migration to the new "share" behavior.


Revision tags: 1.25.0-1, 1.25.0
# 1927:ac8d11e34427 03-Aug-2021 Max Romanov

Fixed dead assignments.

Found by Clang Static Analyzer.


# 1910:b9e844d85f21 02-Jul-2021 Oisin Canty

Ruby: process and thread lifecycle hooks.

This feature allows one to specify blocks of code that are called when certain
lifecycle events occur. A user configures a "hooks" property on the app
conf

Ruby: process and thread lifecycle hooks.

This feature allows one to specify blocks of code that are called when certain
lifecycle events occur. A user configures a "hooks" property on the app
configuration that points to a script. This script will be evaluated on boot
and should contain blocks of code that will be called on specific events.

An example of configuration:

{
"type": "ruby",
"processes": 2,
"threads": 2,
"user": "vagrant",
"group": "vagrant",
"script": "config.ru",
"hooks": "hooks.rb",
"working_directory": "/home/vagrant/unit/rbhooks",
"environment": {
"GEM_HOME": "/home/vagrant/.ruby"
}
}

An example of a valid "hooks.rb" file follows:

File.write("./hooks.#{Process.pid}", "hooks evaluated")

on_worker_boot do
File.write("./worker_boot.#{Process.pid}", "worker booted")
end

on_thread_boot do
File.write("./thread_boot.#{Process.pid}.#{Thread.current.object_id}",
"thread booted")
end

on_thread_shutdown do
File.write("./thread_shutdown.#{Process.pid}.#{Thread.current.object_id}",
"thread shutdown")
end

on_worker_shutdown do
File.write("./worker_shutdown.#{Process.pid}", "worker shutdown")
end

This closes issue #535 on GitHub.

show more ...


Revision tags: 1.24.0-1, 1.24.0
# 1872:9f8df8b810e0 20-May-2021 Oisin Canty

Python: support for multiple targets.


Revision tags: 1.23.0-1, 1.23.0, 1.22.0-1, 1.22.0
# 1788:0fc09c5d1314 03-Feb-2021 Max Romanov

Fixing possible NULL dereference.

For listen socket request reply port can be NULL if Router crashes immediately
after issuing the request.

Found by Coverity (CID 366310).


# 1787:db82aa07015c 03-Feb-2021 Max Romanov

Using shared memory to pass configuration to main process.

This patch is required to remove fragmented messages functionality.


# 1759:196b4d90c8cc 22-Dec-2020 Valentin Bartenev

Python: multiple values in the "path" option.


Revision tags: 1.21.0-1, 1.21.0
# 1697:73a335d2911d 10-Nov-2020 Max Romanov

Python: supporting ASGI legacy protocol.

Introducing manual protocol selection for 'universal' apps and frameworks.


# 1689:e0d01647db76 05-Nov-2020 Max Romanov

Perl: request processing in multiple threads.

This closes #486 issue on GitHub.


# 1687:b9d99e596725 04-Nov-2020 Max Romanov

Ruby: request processing in multiple threads.

This closes #482 issue on GitHub.


# 1684:a10e10f3071f 04-Nov-2020 Max Romanov

Java: request processing in multiple threads.

This closes #458 issue on GitHub.


# 1681:542b5b8c0647 04-Nov-2020 Max Romanov

Python: request processing in multiple threads.

This closes #459 issue on GitHub.


# 1673:883f2f79c2f6 29-Oct-2020 Tiago Natel de Moura

Isolation: mounting of procfs by default when using "rootfs".


Revision tags: 1.20.0-1, 1.20.0
# 1601:365bbeccef1c 18-Sep-2020 Max Romanov

Python: app module callable name configuration.

Now it is possible to specify the name of the application callable using
optional parameter 'callable'. Default value is 'application'.

This closes

Python: app module callable name configuration.

Now it is possible to specify the name of the application callable using
optional parameter 'callable'. Default value is 'application'.

This closes #290 issue on GitHub.

show more ...


1234