aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-08-03 21:59:16 +0200
committerMattias Andrée <maandree@kth.se>2016-08-03 21:59:16 +0200
commitddcdca6a449e0e04f3c2c78741859fe5e32ab7ef (patch)
treedb03f7cd61de35631f7ad993aea3ec3bc2748bd6
parentFix bugs (diff)
downloadcoopgammad-ddcdca6a449e0e04f3c2c78741859fe5e32ab7ef.tar.gz
coopgammad-ddcdca6a449e0e04f3c2c78741859fe5e32ab7ef.tar.bz2
coopgammad-ddcdca6a449e0e04f3c2c78741859fe5e32ab7ef.tar.xz
Fix bugs
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--src/servers/master.c13
1 files changed, 10 insertions, 3 deletions
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;