From 44370a9a0ba2d38d3828a886a0d482dbea0e9fef Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 6 Mar 2014 16:53:07 -0500 Subject: [PATCH] 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 --- pyghmi/ipmi/private/session.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyghmi/ipmi/private/session.py b/pyghmi/ipmi/private/session.py index 69dac31c..a29b0082 100644 --- a/pyghmi/ipmi/private/session.py +++ b/pyghmi/ipmi/private/session.py @@ -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]: