summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-10 14:41:49 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-10 15:59:27 +0200
commit25e76def21829edef7ef9bca0a028cccfabb944a (patch)
treedb9bca81c40407328d9c42d95ac893647b11c3af /src/ipcpd
parent26b20744a441705accbe550aa0b996f8601a9404 (diff)
downloadouroboros-25e76def21829edef7ef9bca0a028cccfabb944a.tar.gz
ouroboros-25e76def21829edef7ef9bca0a028cccfabb944a.zip
lib, irmd, ipcp: Add socket timeout
This will add a timeout to the socket so that a process won't be blocked by the actions of the process with which it is communicating over the socket.
Diffstat (limited to 'src/ipcpd')
-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);