From 077825a09d8aab102a9f6e86cea995439716bb2e Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 28 Apr 2014 14:41:34 +1000 Subject: [PATCH] Use only the one client instance struct in connector, ensuring it gets zeroed that way --- src/connector.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/connector.c b/src/connector.c index 486a9a7e..b0f7040c 100644 --- a/src/connector.c +++ b/src/connector.c @@ -52,26 +52,27 @@ static int client_id; void *acceptor(void *arg) { conn_instance_t *ci = (conn_instance_t *)arg; - client_instance_t cli, *client; + client_instance_t *client; int fd; rename_proc("acceptor"); retry: - cli.address_len = sizeof(cli.address); - fd = accept(ci->serverfd, &cli.address, &cli.address_len); + client = ckzalloc(sizeof(client_instance_t)); + client->address_len = sizeof(client->address); +reaccept: + fd = accept(ci->serverfd, &client->address, &client->address_len); if (unlikely(fd < 0)) { if (interrupted()) - goto retry; + goto reaccept; LOGERR("Failed to accept on socket %d in acceptor", ci->serverfd); + dealloc(client); goto out; } keep_sockalive(fd); LOGINFO("Connected new client %d on socket %d", ci->nfds, fd); - client = ckzalloc(sizeof(client_instance_t)); - memcpy(client, &cli, sizeof(client_instance_t)); client->fd = fd; ck_wlock(&ci->lock);