From 62a0e450895cb5809d182908255c3110e8036dc0 Mon Sep 17 00:00:00 2001 From: Brian Silverman Date: Tue, 28 Jul 2015 13:38:58 -0700 Subject: [PATCH] Fix eventfd read handling under heavy load. I had the assertion below fail occasionally when running the libzmq tests under heavy CPU load on linux 3.16.0-4-amd64. --- src/signaler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/signaler.cpp b/src/signaler.cpp index 1b25ea31..a212c655 100644 --- a/src/signaler.cpp +++ b/src/signaler.cpp @@ -291,10 +291,10 @@ void zmq::signaler_t::recv () ssize_t sz = read (r, &dummy, sizeof (dummy)); errno_assert (sz == sizeof (dummy)); - // If we accidentally grabbed the next signal along with the current + // If we accidentally grabbed the next signal(s) along with the current // one, return it back to the eventfd object. - if (unlikely (dummy == 2)) { - const uint64_t inc = 1; + if (unlikely (dummy > 1)) { + const uint64_t inc = dummy - 1; ssize_t sz2 = write (w, &inc, sizeof (inc)); errno_assert (sz2 == sizeof (inc)); return;