tklauser / llmnrd

Link-Local Multicast Resolution (LLMNR) Daemon for Linux
GNU General Public License v2.0
44 stars 20 forks source link

llmnrd daemon should not use busy waiting for packets #19

Closed pali closed 7 years ago

pali commented 7 years ago

Currently llmnrd daemon sleeps just for 50 miliseconds period and after that every time it check for incomming packet. In most cases there will be no incomming event and so in 99% time this daemon uses CPU just for waiting for packets. Daemon should wait in select syscall for infinite period of time and only incomming event (either packet or signal) should wake it up.

$ strace ./llmnrd
...
select(4, [3], NULL, NULL, {0, 50000})  = 0 (Timeout)
select(4, [3], NULL, NULL, {0, 50000})  = 0 (Timeout)
select(4, [3], NULL, NULL, {0, 50000})  = 0 (Timeout)
select(4, [3], NULL, NULL, {0, 50000})  = 0 (Timeout)
select(4, [3], NULL, NULL, {0, 50000})  = 0 (Timeout)
select(4, [3], NULL, NULL, {0, 50000})  = 0 (Timeout)
select(4, [3], NULL, NULL, {0, 50000})  = 0 (Timeout)
select(4, [3], NULL, NULL, {0, 50000})  = 0 (Timeout)
select(4, [3], NULL, NULL, {0, 50000})  = 0 (Timeout)
select(4, [3], NULL, NULL, {0, 50000})  = 0 (Timeout)
select(4, [3], NULL, NULL, {0, 50000})  = 0 (Timeout)
...