From e3d021b3b193ea4f659d25a8ad6cb27b486f8894 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sat, 7 Jan 2017 17:49:43 +0100 Subject: llmnrd: Don't busy wait in receive loop There is no need to have a timeout for select(2) to check llmnr_running periodically. It can just block until a packet is received and will be interrupted by any terminating signal. Closes #19 Signed-off-by: Tobias Klauser --- llmnr.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/llmnr.c b/llmnr.c index 9db381e..17926a7 100644 --- a/llmnr.c +++ b/llmnr.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2016 Tobias Klauser + * Copyright (C) 2014-2017 Tobias Klauser * * This file is part of llmnrd. * @@ -304,7 +304,6 @@ int llmnr_run(void) while (llmnr_running) { fd_set rfds; - struct timeval tv; int nfds, ret; FD_ZERO(&rfds); @@ -315,10 +314,7 @@ int llmnr_run(void) } else nfds = llmnr_sock_ipv4 + 1; - tv.tv_sec = 0; - tv.tv_usec = 50000; - - ret = select(nfds, &rfds, NULL, NULL, &tv); + ret = select(nfds, &rfds, NULL, NULL, NULL); if (ret < 0) { if (errno != EINTR) log_err("Failed to select() on socket: %s\n", strerror(errno)); -- cgit v1.2.3-54-g00ecf