]> git.meshlink.io Git - catta/commitdiff
* fix compat-howl to work with nautilus
authorLennart Poettering <lennart@poettering.net>
Sun, 16 Oct 2005 01:04:07 +0000 (01:04 +0000)
committerLennart Poettering <lennart@poettering.net>
Sun, 16 Oct 2005 01:04:07 +0000 (01:04 +0000)
* 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-common/simple-watch.c
avahi-compat-howl/compat.c
avahi-compat-howl/funcs.txt
avahi-compat-howl/unsupported.c
avahi-compat-libdns_sd/compat.c

index 6531fb773859dc0d7816908de6cfc1531b52ca23..2a15c5effba9bf26a597052bf6039fb5dc7f7375 100644 (file)
@@ -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;
 
index 0f464638d08c9e483396892cff47bd97bfec2458..120f81baaa6dcd0af97db7b9789e6b0297725132 100644 (file)
@@ -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;
 
index c5f8da992f30bc0d017f0a7d4d9a46f2c1697711..42fbb71a79b7ae6ca9ef2c9c31b578e9aac88d46 100644 (file)
@@ -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
index fd1039d10610346b57f96a9a6cc998f935d78440..09baf137d0b44e82f85e45a6f524f29f6452ef00 100644 (file)
@@ -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,
index e56168b91f859b0f180d70c9ab849dd6b9b26abc..9b399d20d1279065f50efee0e9e2b5bc22b0d445 100644 (file)
@@ -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;