From ad9e16c198de66eeea288db05bda0c58a0fb7f27 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 22 Dec 2010 14:00:28 +0000 Subject: [PATCH] Fix last pthread_join fix commit Call for pthread_join() does not set errno value even though return values looks like that. For now assign errno from return value and still use strerror() to print some error message as this seems to be commonly used. Add also log_sys_error() message for error close of local pipe. --- daemons/clvmd/clvmd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c index ae4da65c3..327a1fb5b 100644 --- a/daemons/clvmd/clvmd.c +++ b/daemons/clvmd/clvmd.c @@ -667,7 +667,8 @@ static int local_pipe_callback(struct local_client *thisfd, char *buf, /* EOF on pipe or an error, close it */ if (len <= 0) { void *ret = &status; - close(thisfd->fd); + if (close(thisfd->fd)) + log_sys_error("close", "local_pipe"); /* Clear out the cross-link */ if (thisfd->bits.pipe.client != NULL) @@ -676,7 +677,8 @@ static int local_pipe_callback(struct local_client *thisfd, char *buf, /* Reap child thread */ if (thisfd->bits.pipe.threadid) { - if (pthread_join(thisfd->bits.pipe.threadid, &ret)) + if ((errno = pthread_join(thisfd->bits.pipe.threadid, + &ret))) log_sys_error("pthread_join", ""); thisfd->bits.pipe.threadid = 0; @@ -1068,8 +1070,8 @@ static int read_from_local_sock(struct local_client *thisfd) pthread_cond_signal(&thisfd->bits.localsock.cond); pthread_mutex_unlock(&thisfd->bits.localsock.mutex); - if (pthread_join(thisfd->bits.localsock.threadid, - (void **) &status)) + if ((errno = pthread_join(thisfd->bits.localsock.threadid, + (void **) &status))) log_sys_error("pthread_join", ""); DEBUGLOG("Joined child thread\n"); -- 2.43.5