Age | Commit message (Collapse) | Author |
|
|
|
It's only marginally shorter then the usual for() loop, but certainly
more readable.
|
|
|
|
Now that listen_fds() have been split out, we can safely move the allocation
of the manager object after doing the forking (the fork is done to notify legcay
init-systems that the fds are ready).
Subsequently, we can merge manager_listen() back into managre_new().
This entails a minor behaviour change: the application of permissions to
static device nodes now happens after the fork (but still before notifying
systemd about being ready).
|
|
This will simply silently fail on non-systemd systems, so there is no reason
to make it conditional.
Also make it clear that we notify systemd about being ready as the last step
before starting the event loop, whereas the forking might need to happen
earlier.
|
|
This will allow us in a follow-up commit to listen to fds before forking and
still allocate the manager only after the fork.
|
|
Hide the differenec in listen_fds, by simply opening the fds
here in case they are not passed in.
|
|
This should have no behavioural change, but it is odd to tie the cgroup cleaning to
whether or not we are passed sockets.
The point really is if we are guaranteed to be in a dedicated cgroup, so instead
check for our parent being PID1 (we already implicitly only do this on systemd
systems).
|
|
If they are passed from PID1 this is not necessary.
|
|
|
|
We used to block all signals, and restore the original signal mask before exec'ing
external processes.
Now we just block the signals we care about and unconditionally unblock all signals
before exec'ing.
|
|
Mostly for documentation purposes.
|
|
The communication channels must all be opened before forknig in daemon mode,
or we cannot guarantee that udevadm will work correctly as soon as udevd is
started.
|
|
In daemon mode we would break sd-event as it cannot work accross different processes.
Simply delay the allocation to after the fork.
|
|
Kay said: 'it is from ancient times, when we started udevd from the
kernel's usermodhelper which had no fd 0,1,2'.
|
|
This notifies PID1 about config being flushed, about shutdown starting and shutdown finalizing.
|
|
Only unset the env var in the workers, but otherwise keep it around in the main daemon.
|
|
Only log about starting in daemon mode, rely on PID1 to log this in notify mode. Also
explicitly set the STATUS variable, as is done in notify mode as is done for other
serivecs.
|
|
This allows us to drop the special sigterm handling in spawn_wait()
as this will now be passed directly to the worker event loop.
We now log failing spawend processes at 'warning' level, and timeouts
are in terms of CLOCK_BOOTTIME when available, otherwise the behavior
is unchanged.
|
|
|
|
Rather than trying to schedule new events on every main-loop iteration, do it explicitly when
processing an event finishes, a worker is killed, a new uevent is received, or the event queue
is explicitly restarted.
|
|
Also move builtin and rules initialization from main loop to
event_queue_start().
No functional change.
|
|
The behavior is mostly unchanged, but rather than only ever calling these functions at
fixed points in the event loop, they are called directly whenever they are invoked.
|
|
We were listening for SIGCHLD in the wrong process.
|
|
This partly reverts:
commit 6d1b1e0bc6bd020218afc5f05286bf372be283d5
Author: Tom Gundersen <teg@jklm.no>
Date: Sun May 24 15:10:04 2015 +0200
udevd: worker - fully clean up unnecessary fds
The inotify-fd _is_ used in the workers, so don't close it! Have a look at
udev-watch.c, which keeps track of the inotify-fd as a global variable
(ugh!).
|
|
We would enforce that events could only be added to the queue from the
main process, but that brake in daemonized mode. Relax the restriction
to only allow one process to add events to the queue.
Reported by Mantas Mikulėnas.
|
|
Initialize structs when declaring rather than using memzero().
|
|
These are only ever used in the parent process, so close them early in the worker.
|
|
|
|
Makes it a bit clearer what is going on, rather than jumping to the end of main().
No functional change.
|
|
First parse config, then sanitize environment before donig any further setup.
No functional change.
|
|
No functional change.
|
|
This uses kill_and_sigcont() instead of kill(), otherwise no functional change.
|
|
We were returning rather than continuing in some cases. The intention
was always to fully process all pending events before returning
from the SIGCHLD handler. Restore this behaviour.
|
|
No functional change.
|
|
No functional change.
|
|
This way it is more obvious that the queue flag file is always
up-to-date. Moreover, we only have to touch/unlink it when the
first/last event is allocated/freed.
|
|
EAGAIN means there are no more messages to read, so give up. EINTR means we got interrupted
reading a message, so try again.
|
|
When notifying the main daemon about event completion, make sure the message is sent
successfully, and not interrupted.
|
|
|
|
Stop relying on global variables in event handlers, and move them
all to a Manager object instead.
|
|
|
|
This avoids updating the flag files twice for every loop, and also removes another dependency
in the main-loop, so we are freer to reshufle it as we want.
|
|
Rather than skippling ctrl handling whenever we have handlede inotify events
(and hence may have synthesized a 'change' event), just call the uevent
handling explicitly from on_inotify() so that the event queue is up-to-date.
|
|
|
|
This allows us to simplify the ctrl_msg handler. Eventually all this global state should move to
a Manager object or so.
|
|
|
|
Simply query the size of the hashmap keeping all the worker contexts instead.
|
|
This makes the code somewhat more readable.
|
|
Make the worker context have the same life-span as the worker process. It is created on fork()
and free'd on SIGCHLD.
The change means that we can get worker_returned() for a worker context that is no longer around,
this is not a problem and we can just drop the message. The only use for worker_returned() is to
know to reschedule events to workers that are still around, so if the worker has already exited
it is not important to keep track of. We still print a debug statement in this case to be on the
safe side.
|