From df2bce44795e44f9bda3036091597649cdc56649 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Sun, 8 Mar 2009 12:56:44 -0400 Subject: [PATCH] Check for EDEADLK in MUTEX_UNLOCK. It can be ignored since EDEADLK in this case only means that the mutex isn't locked. In cleanup_cb(), log the exit before freeing the client_thread_s. --- src/commands.c | 7 +------ src/lock.h | 2 +- src/pwmd.c | 4 +--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/commands.c b/src/commands.c index 0657f6a9..002f42df 100644 --- a/src/commands.c +++ b/src/commands.c @@ -120,12 +120,7 @@ void unlock_file_mutex(struct client_s *client) } CACHE_UNLOCK; - - if (pth_mutex_acquire(m, TRUE, NULL)) - pth_mutex_release(m); - else - MUTEX_UNLOCK(m); - + MUTEX_UNLOCK(m); client->has_lock = client->is_lock_cmd = FALSE; } diff --git a/src/lock.h b/src/lock.h index 64086d44..37066844 100644 --- a/src/lock.h +++ b/src/lock.h @@ -46,7 +46,7 @@ #define MUTEX_UNLOCK(m) \ MUTEX_UNLOCK_DEBUG \ - if (pth_mutex_release(m) == FALSE) { \ + if (!pth_mutex_release(m) && errno != EDEADLK) { \ log_write("%s(%i): %s: UNLOCK", __FILE__, __LINE__, strerror(errno)); \ assert(0); \ } diff --git a/src/pwmd.c b/src/pwmd.c index 9a8b0c5f..6b1e5dab 100644 --- a/src/pwmd.c +++ b/src/pwmd.c @@ -466,8 +466,8 @@ static void cleanup_cb(void *arg) cleanup_crypto(&cl->crypto); g_free(cl); - g_free(cn); log_write(N_("exiting, fd=%i"), cn->fd); + g_free(cn); send_status_all(STATUS_CLIENTS); } @@ -553,7 +553,6 @@ static void *client_thread(void *data) } #endif - fprintf(stderr, "%s(%i): %p %p\n", __FILE__, __LINE__, cl, cl->crypto); pth_mutex_init(&thd->msg_list_mutex); attr = pth_attr_new(); pth_attr_init(attr); @@ -576,7 +575,6 @@ static void *client_thread(void *data) } send_status_all(STATUS_CLIENTS); - fprintf(stderr, "%s(%i): %p %p\n", __FILE__, __LINE__, cl, cl->crypto); xmlSetStructuredErrorFunc(cl, xml_error_cb); for (;;) { -- 2.11.4.GIT