From d7a3d43eb655e8a34939b0d57f81c2c68987cf8c Mon Sep 17 00:00:00 2001 From: henri Date: Sat, 21 Feb 2015 21:15:21 +0000 Subject: [PATCH] Reduce CPU consumption with nsock engine poll Entering nsock_loop() with the poll engine activated and no registered FD (timers only, for instance) should not directly return, but sleep until next timeout. --- CHANGELOG | 4 ++++ nsock/src/engine_poll.c | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4ddb8fd2d..6a6a3d27c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # Nmap Changelog ($Id$); -*-text-*- +o Reduce CPU consumption when using nsock poll engine with no registered FD, + by actually calling Poll() for the time until timeout, instead of directly + returning zero and entering the loop again. [Henri Doreau] + o Fix ICMP Echo (-PE) host discovery for IPv6, broken since 6.45, caused by failing to set the ICMP ID for outgoing packets which is used to match incoming responses. [Andrew Waters] diff --git a/nsock/src/engine_poll.c b/nsock/src/engine_poll.c index 22e474f26..746435086 100644 --- a/nsock/src/engine_poll.c +++ b/nsock/src/engine_poll.c @@ -347,11 +347,7 @@ int poll_loop(struct npool *nsp, int msec_timeout) { #endif #endif { - if (pinfo->max_fd > -1) - results_left = Poll(pinfo->events, pinfo->max_fd + 1, combined_msecs); - else - results_left = 0; - + results_left = Poll(pinfo->events, pinfo->max_fd + 1, combined_msecs); if (results_left == -1) sock_err = socket_errno(); }