chiark / gitweb /
event: make sure we keep a reference to all events we dispatch while we do so.
authorLennart Poettering <lennart@poettering.net>
Wed, 6 Nov 2013 22:59:07 +0000 (23:59 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 6 Nov 2013 23:13:58 +0000 (00:13 +0100)
src/libsystemd-bus/sd-event.c
src/socket-proxy/socket-proxyd.c

index 9c641c9..97e6db2 100644 (file)
@@ -1614,6 +1614,8 @@ static int source_dispatch(sd_event_source *s) {
                         return r;
         }
 
+        sd_event_source_ref(s);
+
         switch (s->type) {
 
         case SOURCE_IO:
@@ -1645,6 +1647,8 @@ static int source_dispatch(sd_event_source *s) {
                 break;
         }
 
+        sd_event_source_unref(s);
+
         return r;
 }
 
index 1c64c0e..12d58d4 100644 (file)
@@ -338,7 +338,7 @@ static int connection_enable_event_sources(Connection *c, sd_event *event) {
                 r = 0;
 
         if (r < 0) {
-                log_error("Failed to set up server event source: %s", strerror(-r));
+                log_error("Failed to set up client event source: %s", strerror(-r));
                 return r;
         }
 
@@ -434,6 +434,12 @@ static int add_connection_socket(Context *context, sd_event *event, int fd) {
                                 log_error("Failed to add connection socket: %s", strerror(-r));
                                 goto fail;
                         }
+
+                        r = sd_event_source_set_enabled(c->client_event_source, SD_EVENT_ONESHOT);
+                        if (r < 0) {
+                                log_error("Failed to enable oneshot event source: %s", strerror(-r));
+                                goto fail;
+                        }
                 } else {
                         log_error("Failed to connect to remote host: %m");
                         goto fail;