From ed070f4105b7091ff4f7b06622293c9217151e87 Mon Sep 17 00:00:00 2001 From: Christine Caulfield Date: Mon, 17 Mar 2008 09:37:47 +0000 Subject: [PATCH] Fix potential thread deadlock. Also make local sockets non-blocking. --- WHATS_NEW | 1 + daemons/clvmd/clvmd.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index e500ef4cc..02690d9c6 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Fix potential deadlock in clvmd thread handling. Refactor text format initialisation into _init_text_import. Escape double quotes and backslashes in external metadata and config data. Add functions for escaping double quotes in strings. diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c index 49cdcbea4..389404a1f 100644 --- a/daemons/clvmd/clvmd.c +++ b/daemons/clvmd/clvmd.c @@ -1416,7 +1416,8 @@ next_pre: DEBUGLOG("Waiting for next pre command\n"); pthread_mutex_lock(&client->bits.localsock.mutex); - if (client->bits.localsock.state != PRE_COMMAND) { + if (client->bits.localsock.state != PRE_COMMAND && + !client->bits.localsock.finished) { pthread_cond_wait(&client->bits.localsock.cond, &client->bits.localsock.mutex); } @@ -1822,8 +1823,9 @@ static int open_local_sock() log_error("Can't create local socket: %m"); return -1; } - /* Set Close-on-exec */ + /* Set Close-on-exec & non-blocking */ fcntl(local_socket, F_SETFD, 1); + fcntl(local_socket, F_SETFL, fcntl(local_socket, F_GETFL, 0) | O_NONBLOCK); memset(&sockaddr, 0, sizeof(sockaddr)); memcpy(sockaddr.sun_path, CLVMD_SOCKNAME, sizeof(CLVMD_SOCKNAME));