summaryrefslogtreecommitdiffstats
path: root/avahi-compat-howl/compat.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-10-16 01:04:07 +0000
committerLennart Poettering <lennart@poettering.net>2005-10-16 01:04:07 +0000
commit9da0241b9c1bf751605ba11fa6d4c75e34fe5f2b (patch)
tree9d0369dc720ccef3585a7128094dd615e7584a6f /avahi-compat-howl/compat.c
parent10bb2c127df147851330f6c06ba38198829d15e9 (diff)
* 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
Diffstat (limited to 'avahi-compat-howl/compat.c')
-rw-r--r--avahi-compat-howl/compat.c50
1 files changed, 42 insertions, 8 deletions
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;