diff options
author | dimitri staessens <[email protected]> | 2017-04-05 20:02:28 +0200 |
---|---|---|
committer | dimitri staessens <[email protected]> | 2017-04-06 10:36:24 +0200 |
commit | e1c0714d5827cd927961f3a687d9720e6e9aa802 (patch) | |
tree | d8e793cffbe829d64855eaa5a429b90ebe3dc3a4 /src/irmd/ipcp.c | |
parent | c6ad4f96f8bb2f1ee749e92308e7173523ddd0b8 (diff) | |
download | ouroboros-e1c0714d5827cd927961f3a687d9720e6e9aa802.tar.gz ouroboros-e1c0714d5827cd927961f3a687d9720e6e9aa802.zip |
lib, irmd: Implement flow allocation timeout
Setting the timeouts on flow_alloc and flow_accept will now work. This
makes some changes to the UNIX sockets used for management
communication between the APs, IRMd and IPCPs.
Diffstat (limited to 'src/irmd/ipcp.c')
-rw-r--r-- | src/irmd/ipcp.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c index a8263580..eb0c2de0 100644 --- a/src/irmd/ipcp.c +++ b/src/irmd/ipcp.c @@ -53,10 +53,12 @@ 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}; + if (kill(api, 0) < 0) + return NULL; + sock_path = ipcp_sock_path(api); if (sock_path == NULL) return NULL; @@ -67,10 +69,6 @@ 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); @@ -85,6 +83,10 @@ 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."); + pthread_cleanup_push(close_ptr, (void *) &sockfd); pthread_cleanup_push((void (*)(void *)) free, (void *) buf.data); @@ -184,7 +186,7 @@ int ipcp_destroy(pid_t api) return 0; } -int ipcp_bootstrap(pid_t api, +int ipcp_bootstrap(pid_t api, dif_config_msg_t * conf) { ipcp_msg_t msg = IPCP_MSG__INIT; |