Commit 1a6b5d0d authored by Franksen, Benjamin's avatar Franksen, Benjamin
Browse files

scan/ellsi: set recv timeout to 5 seconds unconditionally


This is so we can reliably detect disconnect even in cases such as an
unplugged network cable: the server sends a heartbeat every 2.5 seconds. If
we fail to read anything after 5 seconds we can safely assume the server is
dead or unreachable.
parent ce6ba54e
......@@ -434,7 +434,7 @@ static int ellsi_connect(void *pvt) {
fprintf(stderr, "ellsi_connect: error in socket connect (%s)\n", ERRNO_STR(buf));
return -1;
}
/* set recv timout for during connect */
/* set recv timout to 5 seconds so we can detect missing heartbeat (every 2.5 seconds) */
if (setsockopt(state->sock, SOL_SOCKET, SO_RCVTIMEO, &tmo, sizeof(tmo)) < 0) {
fprintf(stderr, "ellsi_connect: error setting socket option SO_RCVTIMEO (%s)\n",
ERRNO_STR(buf));
......@@ -452,13 +452,6 @@ static int ellsi_connect(void *pvt) {
if (ellsi_add_can_ids(state)) {
return -1;
}
/* reset timout for recv operation to zero (default, infinite) */
tmo.tv_sec = 0;
if (setsockopt(state->sock, SOL_SOCKET, SO_RCVTIMEO, &tmo, sizeof(tmo)) < 0) {
fprintf(stderr, "ellsi_connect: error resetting socket option SO_RCVTIMEO (%s)\n",
ERRNO_STR(buf));
return -1;
}
return 0;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment