X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-common%2Fsimple-watch.c;h=c970c3c4afdb5fedd9d2f1d5aaa9f17889bb5d70;hb=b177bc98ac5b0e8b59f00becffadda7ceeb32553;hp=b8a1b8207ccf280af0c1735bd939ff6dd3d57610;hpb=d3e893754d3158b72d488e515535dfcac980e1c3;p=catta diff --git a/avahi-common/simple-watch.c b/avahi-common/simple-watch.c index b8a1b82..c970c3c 100644 --- a/avahi-common/simple-watch.c +++ b/avahi-common/simple-watch.c @@ -31,9 +31,9 @@ #include #include -#include -#include - +#include "llist.h" +#include "malloc.h" +#include "timeval.h" #include "simple-watch.h" struct AvahiWatch { @@ -153,6 +153,7 @@ static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event w->pollfd.fd = fd; w->pollfd.events = event; + w->pollfd.revents = 0; w->callback = callback; w->userdata = userdata; @@ -518,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; @@ -618,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); } @@ -639,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; }