From bbdcdc12b2240e00f6ab8ff105e954629412b234 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Fri, 8 Nov 2019 13:10:49 +0100
Subject: [PATCH 173/180] daemons: check for non-zero thread_id

Do not call pthread_join if thread_id would be 0.
---
 libdaemon/server/daemon-server.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c
index aa9ff2a..9408440 100644
--- a/libdaemon/server/daemon-server.c
+++ b/libdaemon/server/daemon-server.c
@@ -560,7 +560,8 @@ static void _reap(daemon_state s, int waiting)
 
 	while (ts) {
 		if (waiting || !ts->active) {
-			if ((errno = pthread_join(ts->client.thread_id, &rv)))
+			if (ts->client.thread_id &&
+			    (errno = pthread_join(ts->client.thread_id, &rv)))
 				ERROR(&s, "pthread_join failed: %s", strerror(errno));
 			last->next = ts->next;
 			dm_free(ts);
-- 
1.8.3.1

