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 (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:

11
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);

Loading…
Cancel
Save