summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--avahi-common/simple-watch.c2
-rw-r--r--avahi-compat-howl/compat.c50
-rw-r--r--avahi-compat-howl/funcs.txt8
-rw-r--r--avahi-compat-howl/unsupported.c11
-rw-r--r--avahi-compat-libdns_sd/compat.c25
5 files changed, 65 insertions, 31 deletions
diff --git a/avahi-common/simple-watch.c b/avahi-common/simple-watch.c
index 6531fb7..2a15c5e 100644
--- a/avahi-common/simple-watch.c
+++ b/avahi-common/simple-watch.c
@@ -519,7 +519,7 @@ 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;
diff --git a/avahi-compat-howl/compat.c b/avahi-compat-howl/compat.c
index 0f46463..120f81b 100644
--- a/avahi-compat-howl/compat.c
+++ b/avahi-compat-howl/compat.c
@@ -43,7 +43,8 @@
enum {
COMMAND_POLL = 'p',
COMMAND_QUIT = 'q',
- COMMAND_POLL_DONE = 'P'
+ COMMAND_POLL_DONE = 'P',
+ COMMAND_POLL_FAILED = 'F'
};
typedef enum {
@@ -183,22 +184,32 @@ static void * thread_func(void *data) {
switch (command) {
- case COMMAND_POLL:
+ case COMMAND_POLL: {
+ int ret;
ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex));
+
+ for (;;) {
+ errno = 0;
- if (avahi_simple_poll_run(self->simple_poll) < 0) {
- fprintf(stderr, __FILE__": avahi_simple_poll_run() failed.\n");
- ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
+ if ((ret = avahi_simple_poll_run(self->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(&self->mutex));
- if (write_command(self->thread_fd, COMMAND_POLL_DONE) < 0)
+ if (write_command(self->thread_fd, ret < 0 ? COMMAND_POLL_FAILED : COMMAND_POLL_DONE) < 0)
break;
break;
+ }
case COMMAND_QUIT:
return NULL;
@@ -574,8 +585,10 @@ sw_result sw_salt_step(sw_salt self, sw_uint32 * msec) {
sw_result sw_salt_run(sw_salt self) {
sw_result ret;
-
+
AVAHI_WARN_LINKAGE;
+
+ assert(self);
for (;;)
if ((ret = sw_salt_step(self, NULL)) != SW_OKAY)
@@ -585,12 +598,33 @@ sw_result sw_salt_run(sw_salt self) {
sw_result sw_salt_stop_run(sw_salt self) {
AVAHI_WARN_LINKAGE;
+ assert(self);
+
if (stop_thread((sw_discovery) self) < 0)
return SW_E_UNKNOWN;
return SW_OKAY;
}
+sw_result sw_salt_lock(sw_salt self) {
+ AVAHI_WARN_LINKAGE;
+
+ assert(self);
+ ASSERT_SUCCESS(pthread_mutex_lock(&((sw_discovery) self)->mutex));
+
+ return SW_OKAY;
+}
+
+sw_result sw_salt_unlock(sw_salt self) {
+ assert(self);
+
+ AVAHI_WARN_LINKAGE;
+
+ ASSERT_SUCCESS(pthread_mutex_unlock(&((sw_discovery) self)->mutex));
+
+ return SW_OKAY;
+}
+
static void reg_report_status(oid_data *data, sw_discovery_publish_status status) {
sw_discovery_publish_reply reply;
diff --git a/avahi-compat-howl/funcs.txt b/avahi-compat-howl/funcs.txt
index c5f8da9..42fbb71 100644
--- a/avahi-compat-howl/funcs.txt
+++ b/avahi-compat-howl/funcs.txt
@@ -40,6 +40,10 @@ sw_ipv4_address_decompose
sw_ipv4_address_equals
sw_salt_step
+sw_salt_lock
+sw_salt_unlock
+sw_salt_run
+sw_salt_stop_run
-- Unsupported but Relevant --
@@ -69,10 +73,6 @@ sw_salt_register_network_interface
sw_salt_unregister_network_interface_handler
sw_salt_register_signal
sw_salt_unregister_signal
-sw_salt_lock
-sw_salt_unlock
-sw_salt_run
-sw_salt_stop_run
sw_print_assert
sw_print_debug
sw_tcp_socket_init
diff --git a/avahi-compat-howl/unsupported.c b/avahi-compat-howl/unsupported.c
index fd1039d..09baf13 100644
--- a/avahi-compat-howl/unsupported.c
+++ b/avahi-compat-howl/unsupported.c
@@ -190,17 +190,6 @@ sw_result sw_salt_unregister_signal(
return SW_E_NO_IMPL;
}
-sw_result sw_salt_lock(sw_salt self) {
- AVAHI_WARN_UNSUPPORTED;
- return SW_E_NO_IMPL;
-}
-
-sw_result sw_salt_unlock(sw_salt self) {
- AVAHI_WARN_UNSUPPORTED;
- return SW_E_NO_IMPL;
-}
-
-
void sw_print_assert(
int code,
sw_const_string assert_string,
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;