Browse Source

Close sockets immediately after every received message in connector and stratifier

master
Con Kolivas 11 years ago
parent
commit
b6030d3809
  1. 9
      src/connector.c
  2. 11
      src/stratifier.c

9
src/connector.c

@ -291,15 +291,15 @@ retry:
if (sockd < 0) { if (sockd < 0) {
if (interrupted()) if (interrupted())
goto retry; goto retry;
LOGERR("Failed to accept on connector socket"); LOGERR("Failed to accept on connector socket, retrying in 5s");
ret = 1; sleep(5);
goto out; goto retry;
} }
buf = recv_unix_msg(sockd); buf = recv_unix_msg(sockd);
close(sockd);
if (!buf) { if (!buf) {
LOGWARNING("Failed to get message in connector_loop"); LOGWARNING("Failed to get message in connector_loop");
close(sockd);
goto retry; goto retry;
} }
LOGDEBUG("Connector received message: %s", buf); LOGDEBUG("Connector received message: %s", buf);
@ -319,7 +319,6 @@ retry:
realloc_strcat(&buf, "\n"); realloc_strcat(&buf, "\n");
send_client(ckp, ci, client_id, buf); send_client(ckp, ci, client_id, buf);
json_decref(json_msg); json_decref(json_msg);
close(sockd);
goto retry; goto retry;
out: out:

11
src/stratifier.c

@ -447,7 +447,8 @@ retry:
if (selret < 0) { if (selret < 0) {
if (interrupted()) if (interrupted())
goto retry; goto retry;
LOGERR("Select failed in strat_loop"); LOGERR("Select failed in strat_loop, killing stratifier!");
sleep(5);
ret = 1; ret = 1;
goto out; goto out;
} }
@ -460,16 +461,16 @@ retry:
if (sockd < 0) { if (sockd < 0) {
if (interrupted()) if (interrupted())
goto retry; goto retry;
LOGERR("Failed to accept on stratifier socket"); LOGERR("Failed to accept on stratifier socket, retrying in 5s");
ret = 1; sleep(5);
goto out; goto retry;
} }
dealloc(buf); dealloc(buf);
buf = recv_unix_msg(sockd); buf = recv_unix_msg(sockd);
close(sockd);
if (!buf) { if (!buf) {
LOGWARNING("Failed to get message in strat_loop"); LOGWARNING("Failed to get message in strat_loop");
close(sockd);
goto retry; goto retry;
} }
LOGDEBUG("Stratifier received request: %s", buf); LOGDEBUG("Stratifier received request: %s", buf);

Loading…
Cancel
Save