From c932cc44b492eb4e10a395e7cd4300b5c39f0808 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Sat, 21 Mar 2009 15:34:39 -0400 Subject: [PATCH] Make client_msg_thread() joinable. --- src/pwmd.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/pwmd.c b/src/pwmd.c index 72b424d0..74f96048 100644 --- a/src/pwmd.c +++ b/src/pwmd.c @@ -463,12 +463,9 @@ static void *client_thread(void *data) struct client_thread_s *thd = data; struct client_s *cl = g_malloc0(sizeof(struct client_s)); gpg_error_t rc; - pth_attr_t attr = pth_attr_of(pth_self()); + pth_attr_t attr; gint n; - pth_attr_set(attr, PTH_ATTR_NAME, __FUNCTION__); - pth_attr_destroy(attr); - /* * Prevent a race condition with init_new_connection() if this thread * fails (returns) for some reason before init_new_connection() releases @@ -483,6 +480,9 @@ static void *client_thread(void *data) goto fail; } + attr = pth_attr_of(pth_self()); + pth_attr_set(attr, PTH_ATTR_NAME, __FUNCTION__); + pth_attr_destroy(attr); thd->cl = cl; cl->thd = thd; @@ -508,6 +508,7 @@ static void *client_thread(void *data) pth_mutex_init(&thd->msg_list_mutex); attr = pth_attr_new(); pth_attr_init(attr); + pth_attr_set(attr, PTH_ATTR_JOINABLE, TRUE); thd->msg_tid = pth_spawn(attr, client_msg_thread, thd); n = errno; pth_attr_destroy(attr); @@ -1346,7 +1347,7 @@ try_decrypt: return TRUE; } -static void init_new_connection(gint fd, gchar *addr) +static void init_new_connection(gint fd) { pth_attr_t attr; struct client_thread_s *new; @@ -1380,12 +1381,7 @@ static void init_new_connection(gint fd, gchar *addr) cn_thread_list = g_slist_append(cn_thread_list, new); MUTEX_UNLOCK(&cn_mutex); - - if (addr) - log_write(N_("new connection: tid=%p, fd=%i, addr=%s"), new->tid, fd, - addr); - else - log_write(N_("new connection: tid=%p, fd=%i"), new->tid, fd); + log_write(N_("new connection: tid=%p, fd=%i"), new->tid, fd); } static void *accept_thread(void *arg) @@ -1415,7 +1411,7 @@ static void *accept_thread(void *arg) continue; } - init_new_connection(fd, NULL); + init_new_connection(fd); } /* Just in case accept() failed for some reason other than EBADF */ -- 2.11.4.GIT