<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - sd_event fails miserably with more than one child process"
href="https://bugs.freedesktop.org/show_bug.cgi?id=84659">84659</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>sd_event fails miserably with more than one child process
</td>
</tr>
<tr>
<th>Product</th>
<td>systemd
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux (All)
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>general
</td>
</tr>
<tr>
<th>Assignee</th>
<td>systemd-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mustrumr97@gmail.com
</td>
</tr>
<tr>
<th>QA Contact</th>
<td>systemd-bugs@lists.freedesktop.org
</td>
</tr></table>
<p>
<div>
<pre>When a child event is disabled (in order to be freed) and there is no SIGCHLD
signal event, sd_event_source_set_enabled will disable SIGCHLD even if there
are other child events.
My fix also removes some unneeded signalfd updates.
diff --git a/src/libsystemd/sd-event/sd-event.c
b/src/libsystemd/sd-event/sd-event.c
index b56182d..42b176b 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -1055,11 +1055,9 @@ _public_ int sd_event_add_child(
return r;
}
- e->n_enabled_child_sources ++;
-
assert_se(sigaddset(&e->sigset, SIGCHLD) == 0);
- if (!e->signal_sources || !e->signal_sources[SIGCHLD]) {
+ if ((!e->signal_sources || !e->signal_sources[SIGCHLD]) &&
e->n_enabled_child_sources == 0) {
r = event_update_signal_fd(e);
if (r < 0) {
source_free(s);
@@ -1067,6 +1065,8 @@ _public_ int sd_event_add_child(
}
}
+ e->n_enabled_child_sources ++;
+
e->need_process_child = true;
if (ret)
@@ -1451,7 +1451,7 @@ _public_ int sd_event_source_set_enabled(sd_event_source
*s, int m) {
assert(s->event->n_enabled_child_sources > 0);
s->event->n_enabled_child_sources--;
- if (!s->event->signal_sources ||
!s->event->signal_sources[SIGCHLD]) {
+ if ((!s->event->signal_sources ||
!s->event->signal_sources[SIGCHLD]) && s->event->n_enabled_child_sources == 0)
{
assert_se(sigdelset(&s->event->sigset,
SIGCHLD) == 0);
event_update_signal_fd(s->event);
}
@@ -1511,12 +1511,12 @@ _public_ int
sd_event_source_set_enabled(sd_event_source *s, int m) {
case SOURCE_CHILD:
if (s->enabled == SD_EVENT_OFF) {
- s->event->n_enabled_child_sources++;
-
- if (!s->event->signal_sources ||
!s->event->signal_sources[SIGCHLD]) {
+ if ((!s->event->signal_sources ||
!s->event->signal_sources[SIGCHLD]) && s->event->n_enabled_child_sources == 0)
{
assert_se(sigaddset(&s->event->sigset,
SIGCHLD) == 0);
event_update_signal_fd(s->event);
}
+
+ s->event->n_enabled_child_sources++;
}
s->enabled = m;</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>