The original code used fread(), which on some libc implementions
(ie glibc 2.17) would pre-read a full 4K (PAGE_SIZE) of the
PCI config space, when only 64 bytes were requested.
I have recently come across PCIe hardware which responds with
Completion Timeouts when accesses above 256 bytes are attempted.
This can cause server systems with GHES/AEPI support to cause
and immediate kernel panic due to the failed PCI transaction.
This change replaces the buffered fread() with an explict
unbuffered read() of 64 bytes, which corrects this issue by
only reading the guaranteed first 64 bytes of PCIe config space.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Makes it a bit clearer what is going on, rather than jumping to the end of main().
No functional change.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
EAGAIN means there are no more messages to read, so give up. EINTR means we got interrupted
reading a message, so try again.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
When notifying the main daemon about event completion, make sure the message is sent
successfully, and not interrupted.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
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.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
This allows us to simplify the ctrl_msg handler. Eventually all this global state should move to
a Manager object or so.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
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.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
We used to use this to track failed events so they could be retriggered,
but that is no longer done, so the code can be dropped.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Various cleanups, be stricter when parsing unit paths.
Most importantly: return the root slice "-.slice" when asked for slice
of paths that contain no slice component.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
When parsing a unit with a trailing slash after an escaped line break, like
ExecStart=/bin/echo 'foo \
bar'
the split() function (through config_parse()) asserted and crashed pid 1:
Assertion 'current[*l + 1] == quotechars[0]' failed at ../src/shared/util.c:583, function split(). Aborting.
Fix this by returning an error in this case ("trailing garbage").
Add corresponding test case. Also fix the missing "unit" argument of
config_parse_exec() in the comment.
https://launchpad.net/bugs/1447243
If the main daemon is not notified about a worker finishing an event
the refcounting of the worker struct will be wrong, and we will lose
track of the number of children we have to wait for.
This should not happen, but if it does we better complain loudly about
it. Worst case udev will wait for 30 seconsd at shutdown waiting for
nonexistent workers.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>