From 9d793945f0e9c91823429be342e139aae457060d Mon Sep 17 00:00:00 2001 From: ckolivas Date: Mon, 27 Oct 2014 23:35:16 +1100 Subject: [PATCH] Only allow one send_recv_proc at a time --- src/ckpool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ckpool.c b/src/ckpool.c index 0ac0de3a..59b17caf 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -489,16 +489,20 @@ char *_send_recv_proc(proc_instance_t *pi, const char *msg, const char *file, co LOGALERT("Attempting to send message %s to dead process %s", msg, pi->processname); goto out; } + + mutex_lock(&pi->lock); sockd = open_unix_client(path); if (unlikely(sockd < 0)) { LOGWARNING("Failed to open socket %s in send_recv_proc", path); - goto out; + goto out_unlock; } if (unlikely(!send_unix_msg(sockd, msg))) LOGWARNING("Failed to send %s to socket %s", msg, path); else buf = recv_unix_msg(sockd); Close(sockd); +out_unlock: + mutex_unlock(&pi->lock); out: if (unlikely(!buf)) LOGERR("Failure in send_recv_proc from %s %s:%d", file, func, line);