Skip to content

Commit

Permalink
Make sockets non-blocking when making use of busy-wait polling
Browse files Browse the repository at this point in the history
  • Loading branch information
blechschmidt committed Apr 4, 2018
1 parent d02f6fa commit 821fca6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,18 @@ void read_control_message(socket_info_t *socket_info)

}

void make_query_sockets_nonblocking()
{
for(size_t i = 0; i < context.sockets.interfaces4.len; i++)
{
socket_noblock(((socket_info_t*)context.sockets.interfaces4.data) + i);
}
for(size_t i = 0; i < context.sockets.interfaces6.len; i++)
{
socket_noblock(((socket_info_t*)context.sockets.interfaces6.data) + i);
}
}

void run()
{
static char multiproc_outfile_name[8192];
Expand Down Expand Up @@ -1558,6 +1570,10 @@ void run()
add_sockets(context.epollfd, socket_events, EPOLL_CTL_ADD, &context.sockets.interfaces6);
}
#endif
if(context.cmd_args.busypoll)
{
make_query_sockets_nonblocking();
}


clock_gettime(CLOCK_MONOTONIC, &context.stats.start_time);
Expand Down Expand Up @@ -1619,7 +1635,7 @@ void run()
}
for(size_t i = 0; i < context.sockets.interfaces6.len; i++)
{
can_read(((socket_info_t*)context.sockets.interfaces4.data) + i);
can_read(((socket_info_t*)context.sockets.interfaces6.data) + i);
}
timed_ring_handle(&context.ring, ring_timeout);

Expand Down

0 comments on commit 821fca6

Please sign in to comment.