Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/signaler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,18 +279,23 @@ void zmq::signaler_t::recv ()
#if defined ZMQ_HAVE_EVENTFD
uint64_t dummy;
ssize_t sz = read (r, &dummy, sizeof (dummy));
errno_assert (sz == sizeof (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 sz2 = write (w, &inc, sizeof (inc));
errno_assert (sz2 == sizeof (inc));
return;
}

zmq_assert (dummy == 1);
if (sz == -1) {
errno_assert (errno == EAGAIN);
}
else {
errno_assert (sz == sizeof (dummy));

// If we accidentally grabbed the next signal(s) along with the current
// one, return it back to the eventfd object.
if (unlikely (dummy > 1)) {
const uint64_t inc = dummy - 1;
ssize_t sz2 = write (w, &inc, sizeof (inc));
errno_assert (sz2 == sizeof (inc));
return;
}
zmq_assert (dummy == 1);
}
#else
unsigned char dummy;
#if defined ZMQ_HAVE_WINDOWS
Expand Down