From b6030d38098d0a43866fb7d90aa907d7d9c94e86 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 26 Apr 2014 08:54:18 +1000 Subject: [PATCH] Close sockets immediately after every received message in connector and stratifier --- src/connector.c | 9 ++++----- src/stratifier.c | 11 ++++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/connector.c b/src/connector.c index d95a4bc1..07b75566 100644 --- a/src/connector.c +++ b/src/connector.c @@ -291,15 +291,15 @@ retry: if (sockd < 0) { if (interrupted()) goto retry; - LOGERR("Failed to accept on connector socket"); - ret = 1; - goto out; + LOGERR("Failed to accept on connector socket, retrying in 5s"); + sleep(5); + goto retry; } buf = recv_unix_msg(sockd); + close(sockd); if (!buf) { LOGWARNING("Failed to get message in connector_loop"); - close(sockd); goto retry; } LOGDEBUG("Connector received message: %s", buf); @@ -319,7 +319,6 @@ retry: realloc_strcat(&buf, "\n"); send_client(ckp, ci, client_id, buf); json_decref(json_msg); - close(sockd); goto retry; out: diff --git a/src/stratifier.c b/src/stratifier.c index 375f233a..864ed287 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -447,7 +447,8 @@ retry: if (selret < 0) { if (interrupted()) goto retry; - LOGERR("Select failed in strat_loop"); + LOGERR("Select failed in strat_loop, killing stratifier!"); + sleep(5); ret = 1; goto out; } @@ -460,16 +461,16 @@ retry: if (sockd < 0) { if (interrupted()) goto retry; - LOGERR("Failed to accept on stratifier socket"); - ret = 1; - goto out; + LOGERR("Failed to accept on stratifier socket, retrying in 5s"); + sleep(5); + goto retry; } dealloc(buf); buf = recv_unix_msg(sockd); + close(sockd); if (!buf) { LOGWARNING("Failed to get message in strat_loop"); - close(sockd); goto retry; } LOGDEBUG("Stratifier received request: %s", buf);