2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-16 04:38:19 +00:00

Fix race condition in requesting delays

When something other than the IO worker thread requests a delay,
there was an interval between pending requests and the new
deadline being calculated during which the non-IO thread would
erroneously consider the old rather than upcoming deadline.
Address by creating a worst case deadline prior to evaluating
pending requests.

Change-Id: Iabde555eb81d2155f4bc4562f0b3a209e1be42a9
This commit is contained in:
Jarrod Johnson 2014-03-06 16:53:07 -05:00
parent 343deca5d9
commit 44370a9a0b

View File

@ -65,6 +65,11 @@ def _ioworker(initialized):
timeout = 0
selectdeadline = _monotonic_time() + timeout
tmplist, _, _ = select.select(iosockets, (), (), timeout)
# pessimistically move out the deadline
# doing it this early (before ioqueue is evaluated)
# this avoids other threads making a bad assumption
# about not having to break into the select
selectdeadline = _monotonic_time() + 300
rdylist = []
for handle in tmplist:
if handle is selectbreak[0]: