]> git.meshlink.io Git - catta/blobdiff - avahi-common/simple-watch.c
Use send_destination for DBus <deny> rule
[catta] / avahi-common / simple-watch.c
index 6531fb773859dc0d7816908de6cfc1531b52ca23..c970c3c4afdb5fedd9d2f1d5aaa9f17889bb5d70 100644 (file)
@@ -31,9 +31,9 @@
 #include <fcntl.h>
 #include <stdio.h>
 
-#include <avahi-common/llist.h>
-#include <avahi-common/malloc.h>
-
+#include "llist.h"
+#include "malloc.h"
+#include "timeval.h"
 #include "simple-watch.h"
 
 struct AvahiWatch {
@@ -519,21 +519,17 @@ finish:
 
 int avahi_simple_poll_run(AvahiSimplePoll *s) {
     assert(s);
-    assert(s->state == STATE_PREPARED);
+    assert(s->state == STATE_PREPARED || s->state == STATE_FAILURE);
     
     s->state = STATE_RUNNING;
 
-    if (s->prepared_timeout != 0) {
-    
-        if (s->poll_func(s->pollfds, s->n_pollfds, s->prepared_timeout, s->poll_func_userdata) < 0) {
-            s->state = STATE_FAILURE;
-            return -1;
-        }
+    if (s->poll_func(s->pollfds, s->n_pollfds, s->prepared_timeout, s->poll_func_userdata) < 0) {
+        s->state = STATE_FAILURE;
+        return -1;
+    }
         
-        /* The poll events are now valid again */
-        s->events_valid = 1;
-    } else
-        s->events_valid = 0;
+    /* The poll events are now valid again */
+    s->events_valid = 1;
         
     /* Update state */
     s->state = STATE_RAN;
@@ -619,7 +615,7 @@ const AvahiPoll* avahi_simple_poll_get(AvahiSimplePoll *s) {
     return &s->api;
 }
 
-static int system_poll(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata) {
+static int system_poll(struct pollfd *ufds, unsigned int nfds, int timeout, AVAHI_GCC_UNUSED void *userdata) {
     return poll(ufds, nfds, timeout);
 }
 
@@ -640,5 +636,6 @@ int avahi_simple_poll_loop(AvahiSimplePoll *s) {
     
     for (;;)
         if ((r = avahi_simple_poll_iterate(s, -1)) != 0)
-            return r;
+            if (r >= 0 || errno != EINTR)
+                return r;
 }