summaryrefslogtreecommitdiffstats
path: root/avahi-compat-libdns_sd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-10-15 02:20:29 +0000
committerLennart Poettering <lennart@poettering.net>2005-10-15 02:20:29 +0000
commit786a6a7fa3840d06e64f7429e134ddb06cc1dedd (patch)
tree70ede9237088f42d9081afe2a8ad1e93c7547196 /avahi-compat-libdns_sd
parentd322a943be5387a539f8f3ea3a19a7e2ed5a55a2 (diff)
minor cleanups
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@763 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-compat-libdns_sd')
-rw-r--r--avahi-compat-libdns_sd/compat.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/avahi-compat-libdns_sd/compat.c b/avahi-compat-libdns_sd/compat.c
index fda5b59..fe481b0 100644
--- a/avahi-compat-libdns_sd/compat.c
+++ b/avahi-compat-libdns_sd/compat.c
@@ -43,9 +43,9 @@
#include "dns_sd.h"
enum {
- COMMAND_POLL = 'P',
- COMMAND_QUIT = 'Q',
- COMMAND_POLLED = 'D'
+ COMMAND_POLL = 'p',
+ COMMAND_QUIT = 'q',
+ COMMAND_POLL_DONE = 'P'
};
struct _DNSServiceRef_t {
@@ -225,7 +225,6 @@ static void * thread_func(void *data) {
case COMMAND_POLL:
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");
@@ -233,12 +232,10 @@ static void * thread_func(void *data) {
break;
}
- if (write_command(sdref->thread_fd, COMMAND_POLLED) < 0) {
- ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
- break;
- }
-
ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
+
+ if (write_command(sdref->thread_fd, COMMAND_POLL_DONE) < 0)
+ break;
break;
@@ -290,7 +287,7 @@ static DNSServiceRef sdref_new(void) {
if (avahi_simple_poll_prepare(sdref->simple_poll, -1) < 0)
goto fail;
- /* Queue a initiall POLL command for the thread */
+ /* Queue an initial POLL command for the thread */
if (write_command(sdref->main_fd, COMMAND_POLL) < 0)
goto fail;
@@ -313,24 +310,25 @@ static void sdref_free(DNSServiceRef sdref) {
assert(sdref);
if (sdref->thread_running) {
- write_command(sdref->main_fd, COMMAND_QUIT);
+ ASSERT_SUCCESS(write_command(sdref->main_fd, COMMAND_QUIT));
avahi_simple_poll_wakeup(sdref->simple_poll);
- pthread_join(sdref->thread, NULL);
+ ASSERT_SUCCESS(pthread_join(sdref->thread, NULL));
}
if (sdref->client)
avahi_client_free(sdref->client);
+ if (sdref->simple_poll)
+ avahi_simple_poll_free(sdref->simple_poll);
+
+
if (sdref->thread_fd >= 0)
close(sdref->thread_fd);
if (sdref->main_fd >= 0)
close(sdref->main_fd);
- if (sdref->simple_poll)
- avahi_simple_poll_free(sdref->simple_poll);
-
- pthread_mutex_destroy(&sdref->mutex);
+ ASSERT_SUCCESS(pthread_mutex_destroy(&sdref->mutex));
avahi_free(sdref->service_name);
avahi_free(sdref->service_name_chosen);
@@ -380,7 +378,7 @@ DNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdref) {
ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
/* Cleanup notification socket */
- if (read_command(sdref->main_fd) != COMMAND_POLLED)
+ if (read_command(sdref->main_fd) != COMMAND_POLL_DONE)
goto finish;
if (avahi_simple_poll_dispatch(sdref->simple_poll) < 0)
@@ -542,7 +540,8 @@ finish:
DNSServiceRefDeallocate(sdref);
return ret;
-}
+xb
+ }
static void service_resolver_callback(
AvahiServiceResolver *r,