chiark / gitweb /
sd-event: restore correct timeout behaviour
[elogind.git] / src / libsystemd / sd-event / sd-event.c
index 06af962dfb8f4a945c8b49bb6f3cd9b5d0161296..53f1904d3de828dcf56b62bcdb81bcdd42423361 100644 (file)
@@ -718,9 +718,9 @@ static sd_event_source *source_new(sd_event *e, bool floating, EventSourceType t
 
         s->n_ref = 1;
         s->event = e;
+        s->floating = floating;
         s->type = type;
         s->pending_index = s->prepare_index = PRIOQ_IDX_NULL;
-        s->floating = floating;
 
         if (!floating)
                 sd_event_ref(e);
@@ -2180,6 +2180,7 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
         unsigned ev_queue_max;
         sd_event_source *p;
         int r, i, m;
+        bool timedout;
 
         assert_return(e, -EINVAL);
         assert_return(!event_pid_changed(e), -ECHILD);
@@ -2226,6 +2227,8 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
                 goto finish;
         }
 
+        timedout = m == 0;
+
         dual_timestamp_get(&e->timestamp);
         e->timestamp_boottime = now(CLOCK_BOOTTIME);
 
@@ -2278,7 +2281,7 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
 
         p = event_next_pending(e);
         if (!p) {
-                r = 1;
+                r = !timedout;
                 goto finish;
         }