summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2015-11-08 11:08:31 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2015-11-11 17:32:17 +0100
commitccc4b1dd548a4411ebfce1320cdb7aed58edafb9 (patch)
tree39fa717e1f79b8b2ef65605a7c4baad9ab601a7b
parentdb6f8315e5c52f09a46c6bd83c1cf17d85d51beb (diff)
downloadNetworkManager-ccc4b1dd548a4411ebfce1320cdb7aed58edafb9.tar.gz
systemd/adapt: return G_SOURCE_REMOVE in time event callback
Differently from GLib timeout sources, systemd ones are always one-shot and therefore we must return G_SOURCE_REMOVE in the callback, otherwise the timer will be scheduled again. In most cases things were working correctly because usually the callback also unreferences the source event, but when this doesn't happen the timer will trigger multiple times as reported in the bug below. https://bugzilla.redhat.com/show_bug.cgi?id=1278506 Fixes: 1b1222ffdf4d022e482c70af6d745cb8fb6c5fdf (cherry picked from commit a74e98bfc6c17f88f55a528fca842340d19ac559)
-rw-r--r--src/dhcp-manager/systemd-dhcp/nm-sd-adapt.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/dhcp-manager/systemd-dhcp/nm-sd-adapt.c b/src/dhcp-manager/systemd-dhcp/nm-sd-adapt.c
index 24b77c528b..3870342c8d 100644
--- a/src/dhcp-manager/systemd-dhcp/nm-sd-adapt.c
+++ b/src/dhcp-manager/systemd-dhcp/nm-sd-adapt.c
@@ -166,21 +166,14 @@ sd_event_add_io (sd_event *e, sd_event_source **s, int fd, uint32_t events, sd_e
static gboolean
time_ready (struct sd_event_source *source)
{
- int r;
- gboolean result;
-
source->refcount++;
- r = source->time.cb (source, source->time.usec, source->user_data);
- if (r < 0 || source->refcount <= 1) {
- source->id = 0;
- result = G_SOURCE_REMOVE;
- } else
- result = G_SOURCE_CONTINUE;
+ source->time.cb (source, source->time.usec, source->user_data);
+ source->id = 0;
sd_event_source_unref (source);
- return result;
+ return G_SOURCE_REMOVE;
}
int