diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-08-10 16:00:10 +0200 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-08-10 16:00:10 +0200 |
commit | 533df37ac3a643017dba96283791d36934e15464 (patch) | |
tree | db9bca81c40407328d9c42d95ac893647b11c3af /src/lib/ipcp.c | |
parent | 26b20744a441705accbe550aa0b996f8601a9404 (diff) | |
parent | 25e76def21829edef7ef9bca0a028cccfabb944a (diff) | |
download | ouroboros-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/lib/ipcp.c')
-rw-r--r-- | src/lib/ipcp.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c index 9ff05e7b..bdc980f9 100644 --- a/src/lib/ipcp.c +++ b/src/lib/ipcp.c @@ -37,6 +37,8 @@ #include <pthread.h> #include <sys/types.h> #include <sys/wait.h> +#include <sys/socket.h> +#include <sys/time.h> static void close_ptr(void * o) { @@ -51,6 +53,8 @@ static ipcp_msg_t * send_recv_ipcp_msg(pid_t api, char * sock_path = NULL; ssize_t count = 0; ipcp_msg_t * recv_msg = NULL; + struct timeval tv = {(SOCKET_TIMEOUT / 1000), + (SOCKET_TIMEOUT % 1000) * 1000}; sock_path = ipcp_sock_path(api); if (sock_path == NULL) @@ -62,6 +66,10 @@ static ipcp_msg_t * send_recv_ipcp_msg(pid_t api, return NULL; } + if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, + (void *) &tv, sizeof(tv))) + LOG_WARN("Failed to set timeout on socket."); + free(sock_path); buf.len = ipcp_msg__get_packed_size(msg); |