summaryrefslogtreecommitdiff
path: root/src/ipcpd/ipcp.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-10 16:00:10 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-10 16:00:10 +0200
commit533df37ac3a643017dba96283791d36934e15464 (patch)
treedb9bca81c40407328d9c42d95ac893647b11c3af /src/ipcpd/ipcp.c
parent26b20744a441705accbe550aa0b996f8601a9404 (diff)
parent25e76def21829edef7ef9bca0a028cccfabb944a (diff)
downloadouroboros-533df37ac3a643017dba96283791d36934e15464.tar.gz
ouroboros-533df37ac3a643017dba96283791d36934e15464.zip
Merged in sandervrijders/ouroboros/be-timeout (pull request #202)
lib, irmd, ipcp: Add socket timeout
Diffstat (limited to 'src/ipcpd/ipcp.c')
-rw-r--r--src/ipcpd/ipcp.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index a9f2b77b..784d845a 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -113,6 +113,9 @@ void * ipcp_main_loop(void * o)
char * sock_path;
+ struct timeval tv = {(SOCKET_TIMEOUT / 1000),
+ (SOCKET_TIMEOUT % 1000) * 1000};
+
if (_ipcp == NULL) {
LOG_ERR("Invalid ipcp struct.");
return (void *) 1;
@@ -141,6 +144,10 @@ void * ipcp_main_loop(void * o)
break;
}
+ if (setsockopt(lsockfd, SOL_SOCKET, SO_RCVTIMEO,
+ (void *) &tv, sizeof(tv)))
+ LOG_WARN("Failed to set timeout on socket.");
+
pthread_cleanup_push(close_ptr, (void *) &lsockfd);
count = read(lsockfd, buf, IPCP_MSG_BUF_SIZE);