#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 {
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;
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);
}
for (;;)
if ((r = avahi_simple_poll_iterate(s, -1)) != 0)
- return r;
+ if (r >= 0 || errno != EINTR)
+ return r;
}