From ddcdca6a449e0e04f3c2c78741859fe5e32ab7ef Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 3 Aug 2016 21:59:16 +0200 Subject: Fix bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/servers/master.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/servers/master.c') diff --git a/src/servers/master.c b/src/servers/master.c index 65012b9..be21b95 100644 --- a/src/servers/master.c +++ b/src/servers/master.c @@ -214,11 +214,17 @@ static int handle_server(void) if (message_initialise(inbound + connections_ptr)) goto fail; } + else + { + connections[connections_ptr] = fd; + ring_initialise(outbound + connections_ptr); + if (message_initialise(inbound + connections_ptr)) + goto fail; + } connections_ptr++; - while (connections_ptr < connections_used) - if (connections[connections_ptr] >= 0) - connections_ptr++; + while ((connections_ptr < connections_used) && (connections[connections_ptr] >= 0)) + connections_ptr++; if (connections_used < connections_ptr) connections_used = connections_ptr; @@ -273,6 +279,7 @@ static int handle_connection(size_t conn) while ((connections_used > 0) && (connections[connections_used - 1] < 0)) connections_used -= 1; message_destroy(msg); + ring_destroy(outbound + conn); if (connection_closed(fd) < 0) return -1; return 1; -- cgit v1.2.3-70-g09d2