]> xenbits.xensource.com Git - xen.git/commit
tools/ocaml/xb: Correct calculations of data/space the ring
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 10 Nov 2015 10:46:44 +0000 (10:46 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 19 Jan 2016 13:41:47 +0000 (13:41 +0000)
commit6150df9f3f99ecbcbd9917002186d1d895b5602e
treeff28686dec1c96a4893d711a3d13ac21cff6d4bc
parentba391da2e7c68aad131159c90733e0d39b85ed37
tools/ocaml/xb: Correct calculations of data/space the ring

ml_interface_{read,write}() would miscalculate the quantity of
data/space in the ring if it crossed the ring boundary, and incorrectly
return a short read/write.

This causes a protocol stall, as either side of the ring ends up waiting
for what they believe to be the other side needing to take the next
action.

Correct the calculations to cope with crossing the ring boundary.

In addition, correct the error detection.  It is a hard error if the
producer index gets more than a ring size ahead of the consumer, or if
the consumer ever overtakes the producer.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: David Scott <dave@recoil.org>
(cherry picked from commit 8a2c11f876e6cf9c74f2bcaed5a997adc57da888)
tools/ocaml/libs/xb/xs_ring_stubs.c