From 9f16513ebe94fbe6f5a32784b06360ff4b5237ae Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Tue, 10 Dec 2019 16:19:25 +0100 Subject: [PATCH] Problem: loop sending signaler event is obscure Solution: add comments and remove continue/break --- src/signaler.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/signaler.cpp b/src/signaler.cpp index b4300d6c..e55360dc 100644 --- a/src/signaler.cpp +++ b/src/signaler.cpp @@ -183,16 +183,15 @@ void zmq::signaler_t::send () ssize_t sz = write (_w, &inc, sizeof (inc)); errno_assert (sz == sizeof (inc)); #elif defined ZMQ_HAVE_WINDOWS - unsigned char dummy = 0; - while (true) { - int nbytes = - ::send (_w, reinterpret_cast (&dummy), sizeof (dummy), 0); + const char dummy = 0; + int nbytes; + do { + nbytes = ::send (_w, &dummy, sizeof (dummy), 0); wsa_assert (nbytes != SOCKET_ERROR); - if (unlikely (nbytes == SOCKET_ERROR)) - continue; - zmq_assert (nbytes == sizeof (dummy)); - break; - } + // wsa_assert does not abort on WSAEWOULDBLOCK. If we get this, we retry. + } while (nbytes == SOCKET_ERROR); + // Given the small size of dummy (should be 1) expect that send was able to send everything. + zmq_assert (nbytes == sizeof (dummy)); #elif defined ZMQ_HAVE_VXWORKS unsigned char dummy = 0; while (true) {