]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commit
Update XENBUS_EVTCHN Wait method to avoid races 8.2.1
authorPaul Durrant <paul.durrant@citrix.com>
Fri, 26 May 2017 19:57:51 +0000 (15:57 -0400)
committerPaul Durrant <paul.durrant@citrix.com>
Wed, 21 Mar 2018 11:25:29 +0000 (11:25 +0000)
commit6790a1da32daaf8cb7626aad3ec533f1a73f7e1c
tree239ac7df3dc5a3a0f14d9964d56332794b0cbd09
parentf646f85788c7da813bb346085354b6aacd587571
Update XENBUS_EVTCHN Wait method to avoid races

Use of the XENBUS_EVTCHN method is prone to races in that a client
usually wants to check that something that should be triggered by an
event and, if it has not occurred, wait for the next event.
The problem is that the client may makes its check, the event then occurs,
and then the client waits. Thus the event is missed and the client only
wakes up when the timeout expires.

This patch changes the Wait method to take an explicit event count to wait
for, and adds a method to sample the current event count. A client can
then avoid a race as described above by sampling the event count first,
making its check and then waiting for the event count to increment by one.
If the event occurred between the check and the wait, the wait will now
return immediately.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
include/evtchn_interface.h
include/revision.h
src/xenbus/evtchn.c
src/xenbus/store.c