summaryrefslogtreecommitdiff
path: root/src/lib/ipcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/ipcp.c')
-rw-r--r--src/lib/ipcp.c8
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);