summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ipcpd/ipcp.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index 44dbb52a..ba89e2cc 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -133,14 +133,12 @@ static void * acceptloop(void * o)
cmd = malloc(sizeof(*cmd));
if (cmd == NULL) {
log_err("Out of memory");
+ close(csockfd);
break;
}
- pthread_mutex_lock(&ipcpi.cmd_lock);
-
cmd->len = read(csockfd, cmd->cbuf, IPCP_MSG_BUF_SIZE);
if (cmd->len <= 0) {
- pthread_mutex_unlock(&ipcpi.cmd_lock);
log_err("Failed to read from socket.");
close(csockfd);
free(cmd);
@@ -149,6 +147,8 @@ static void * acceptloop(void * o)
cmd->fd = csockfd;
+ pthread_mutex_lock(&ipcpi.cmd_lock);
+
list_add(&cmd->next, &ipcpi.cmds);
pthread_cond_signal(&ipcpi.cmd_cond);