summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-12-08 17:21:08 +0100
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-12-08 17:21:08 +0100
commit7c2191370c1c4b891df4d1016baeb220ce1d8dca (patch)
tree870f4b0a6c869d0e82b48260f5c84b0c991ebd74 /src
parentd257e862662f5692c5bdd922adf125a5c1f02e7e (diff)
parent12935222221e316d188075602f07c372e00c855e (diff)
downloadouroboros-7c2191370c1c4b891df4d1016baeb220ce1d8dca.tar.gz
ouroboros-7c2191370c1c4b891df4d1016baeb220ce1d8dca.zip
Merged in dstaesse/ouroboros/be-bsd (pull request #321)
irmd, ipcp: Call select on FreeBSD
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/ipcp.c12
-rw-r--r--src/irmd/main.c12
2 files changed, 22 insertions, 2 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;
diff --git a/src/irmd/main.c b/src/irmd/main.c
index d8cb27fa..dc0c26f2 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -1804,6 +1804,11 @@ void * mainloop(void * o)
(void) o;
while (true) {
+#ifdef __FreeBSD__
+ fd_set fds;
+ struct timeval timeout = {(IRMD_ACCEPT_TIMEOUT / 1000),
+ (IRMD_ACCEPT_TIMEOUT % 1000) * 1000};
+#endif
int cli_sockfd;
irm_msg_t * msg;
ssize_t count;
@@ -1822,7 +1827,12 @@ void * mainloop(void * o)
pthread_rwlock_unlock(&irmd->state_lock);
ret_msg.code = IRM_MSG_CODE__IRM_REPLY;
-
+#ifdef __FreeBSD__
+ FD_ZERO(&fds);
+ FD_SET(irmd->sockfd, &fds);
+ if (select(irmd->sockfd, &fds, NULL, NULL, &timeout) <= 0)
+ continue;
+#endif
cli_sockfd = accept(irmd->sockfd, 0, 0);
if (cli_sockfd < 0)
continue;