summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-udp/main.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-27 12:05:28 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-27 12:05:28 +0200
commitbaafb76b2d69b6cfd4be94b02be68dce86247bc0 (patch)
treec1f810acdc0d88275bdc00008f4898df29fd4e43 /src/ipcpd/shim-udp/main.c
parent8bbc08da60fa088edd7a16754d718a4153db4d01 (diff)
downloadouroboros-baafb76b2d69b6cfd4be94b02be68dce86247bc0.tar.gz
ouroboros-baafb76b2d69b6cfd4be94b02be68dce86247bc0.zip
ipcpd: fixed the shim-udp grinding the cpu
In linux, the select call changes the timeout variable to the time not spent in sleep, causing the timeout to decrease and that loop to grind the cpu. The timeval is now reset to the correct value every loop. Also removed a LOG_ERR message that was hampering performance.
Diffstat (limited to 'src/ipcpd/shim-udp/main.c')
-rw-r--r--src/ipcpd/shim-udp/main.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index 0fc1c78a..db9a89e2 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -62,6 +62,7 @@ typedef ShimUdpMsg shim_udp_msg_t;
#define SHIM_UDP_MSG_SIZE 256
#define SHIM_UDP_MAX_SDU_SIZE 8980
#define DNS_TTL 86400
+#define FD_UPDATE_TIMEOUT 100 /* microseconds */
#define shim_data(type) ((struct ipcp_udp_data *) type->data)
@@ -714,12 +715,13 @@ static void * ipcp_udp_sdu_reader()
int n;
int fd;
char buf[SHIM_UDP_MAX_SDU_SIZE];
- struct timeval tv = {0, 100};
struct sockaddr_in r_saddr;
fd_set read_fds;
int flags;
while (true) {
+ struct timeval tv = {0, FD_UPDATE_TIMEOUT};
+
rw_lock_rdlock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_ENROLLED) {
@@ -759,8 +761,7 @@ static void * ipcp_udp_sdu_reader()
continue;
/* send the sdu to the correct port_id */
- if (ipcp_udp_flow_write(fd, buf, n) < 0)
- LOG_ERR("Failed to write SDU.");
+ ipcp_udp_flow_write(fd, buf, n);
}
}