Commit 6ae1be1a authored by Martin Sustrik's avatar Martin Sustrik

Race condition in eventfd signaler fixed

recv function on eventfd signaler could accidentally
grab two signals instead of one. Fixed.
Signed-off-by: 's avatarMartin Sustrik <sustrik@250bpm.com>
parent 9a9a0cf4
...@@ -206,8 +206,16 @@ void zmq::signaler_t::recv () ...@@ -206,8 +206,16 @@ void zmq::signaler_t::recv ()
uint64_t dummy; uint64_t dummy;
ssize_t sz = read (r, &dummy, sizeof (dummy)); ssize_t sz = read (r, &dummy, sizeof (dummy));
errno_assert (sz == sizeof (dummy)); errno_assert (sz == sizeof (dummy));
if (dummy != 1)
printf ("dummy:%d\n", (int) dummy); // If we accidentally grabbed the next signal along with the current
// one, return it back to the eventfd object.
if (unlikely (dummy == 2)) {
const uint64_t inc = 1;
ssize_t sz = write (w, &inc, sizeof (inc));
errno_assert (sz == sizeof (inc));
return;
}
zmq_assert (dummy == 1); zmq_assert (dummy == 1);
#else #else
unsigned char dummy; unsigned char dummy;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment