summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2016-12-08 16:55:24 +0100
committerdimitri staessens <[email protected]>2016-12-08 17:14:36 +0100
commit12935222221e316d188075602f07c372e00c855e (patch)
treee2cc741142545bf8469d0e550b2b36ca0fc64025 /src/ipcpd
parent82ae7959d21c654fe9fd14de504f47d18b1ebcfc (diff)
downloadouroboros-12935222221e316d188075602f07c372e00c855e.tar.gz
ouroboros-12935222221e316d188075602f07c372e00c855e.zip
irmd, ipcp: Call select on FreeBSD
*BSD accept() doesn't timeout on the timeval set by setsockopt SO_RCVTIMEO. The irmd and ipcp will now call select on the irmd fd with the same timeout.
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/ipcp.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index 00dd69cb..71340fb4 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -230,6 +230,11 @@ void * ipcp_main_loop(void * o)
(void) o;
while (true) {
+#ifdef __FreeBSD__
+ fd_set fds;
+ struct timeval timeout = {(IPCP_ACCEPT_TIMEOUT / 1000),
+ (IPCP_ACCEPT_TIMEOUT % 1000) * 1000};
+#endif
int fd = -1;
pthread_rwlock_rdlock(&ipcpi.state_lock);
@@ -242,7 +247,12 @@ void * ipcp_main_loop(void * o)
pthread_rwlock_unlock(&ipcpi.state_lock);
ret_msg.code = IPCP_MSG_CODE__IPCP_REPLY;
-
+#ifdef __FreeBSD__
+ FD_ZERO(&fds);
+ FD_SET(ipcpi.sockfd, &fds);
+ if (select(ipcpi.sockfd, &fds, NULL, NULL, &timeout) <= 0)
+ continue;
+#endif
lsockfd = accept(ipcpi.sockfd, 0, 0);
if (lsockfd < 0)
continue;