diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2017-01-07 17:49:43 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2017-01-07 17:53:20 +0100 |
commit | e3d021b3b193ea4f659d25a8ad6cb27b486f8894 (patch) | |
tree | a6b8b8a5ed14d83379f56c9ed3a3ec9798fea517 | |
parent | 5fc94b05da91439d9f62e8d1098d463b1f548da4 (diff) |
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 <tklauser@distanz.ch>
-rw-r--r-- | llmnr.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2016 Tobias Klauser <tklauser@distanz.ch> + * Copyright (C) 2014-2017 Tobias Klauser <tklauser@distanz.ch> * * 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)); |