Skip to content

Commit

Permalink
EnginePoll/EngineEpoll: fix polling timeout (#354)
Browse files Browse the repository at this point in the history
* EnginePoll: Force the timeout to be exactly -1 when is negative. The
  implementation of the poll() system call in some OSes, including macOS
  and BSDs, throws an error for arbitrary negative values besides -1.
* EngineEPoll: apply the same fix for coherence and to avoid similar
  issues in the future.
* EnginePoll/EngineEPoll: remove the added millisecond to the timeout,
  when timeo is 0 is ok to pass 0 as timeout to the poll() methods to
  return without blocking triggering any pending events.

Fix #353
  • Loading branch information
volans- authored and thiell committed Sep 5, 2017
1 parent d794d90 commit 5aee33c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/ClusterShell/Engine/EPoll.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ def runloop(self, timeout):
timeo = timeout

self._current_loopcnt += 1
evlist = self.epolling.poll(timeo + 0.001)

if timeo < 0:
poll_timeo = -1
else:
poll_timeo = timeo
evlist = self.epolling.poll(poll_timeo)

except IOError as ex:
# might get interrupted by a signal
Expand Down
7 changes: 6 additions & 1 deletion lib/ClusterShell/Engine/Poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ def runloop(self, timeout):
timeo = timeout

self._current_loopcnt += 1
evlist = self.polling.poll(timeo * 1000.0 + 1.0)

if timeo < 0:
poll_timeo = -1
else:
poll_timeo = timeo * 1000.0
evlist = self.polling.poll(poll_timeo)

except select.error as ex:
# might get interrupted by a signal
Expand Down

0 comments on commit 5aee33c

Please sign in to comment.