From 9da0241b9c1bf751605ba11fa6d4c75e34fe5f2b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 16 Oct 2005 01:04:07 +0000 Subject: * fix compat-howl to work with nautilus * make similar changes to compat-libdns_sd * implement sw_salt_lock()/sw_salt_unlock() in compt-howl * simple-watch: allows immediate rerunning of avahi_simple_poll_run() git-svn-id: file:///home/lennart/svn/public/avahi/trunk@787 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-compat-libdns_sd/compat.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'avahi-compat-libdns_sd') diff --git a/avahi-compat-libdns_sd/compat.c b/avahi-compat-libdns_sd/compat.c index e56168b..9b399d2 100644 --- a/avahi-compat-libdns_sd/compat.c +++ b/avahi-compat-libdns_sd/compat.c @@ -45,7 +45,8 @@ enum { COMMAND_POLL = 'p', COMMAND_QUIT = 'q', - COMMAND_POLL_DONE = 'P' + COMMAND_POLL_DONE = 'P', + COMMAND_POLL_FAILED = 'F' }; struct _DNSServiceRef_t { @@ -222,22 +223,32 @@ static void * thread_func(void *data) { switch (command) { - case COMMAND_POLL: + case COMMAND_POLL: { + int ret; ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex)); - - if (avahi_simple_poll_run(sdref->simple_poll) < 0) { - fprintf(stderr, __FILE__": avahi_simple_poll_run() failed.\n"); - ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); + + for (;;) { + errno = 0; + + if ((ret = avahi_simple_poll_run(sdref->simple_poll)) < 0) { + + if (errno == EINTR) + continue; + + fprintf(stderr, __FILE__": avahi_simple_poll_run() failed: %s\n", strerror(errno)); + } + break; } ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex)); - if (write_command(sdref->thread_fd, COMMAND_POLL_DONE) < 0) + if (write_command(sdref->thread_fd, ret < 0 ? COMMAND_POLL_FAILED : COMMAND_POLL_DONE) < 0) break; break; + } case COMMAND_QUIT: return NULL; -- cgit