guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Ludovic Courtès
Date: Fri, 29 Sep 2023 16:07:10 -0400 (EDT)

branch: master
commit d5582f2a56b6133814bb7d9e951fa247ac544545
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Sep 28 17:43:31 2023 +0200

    remote: Simplify wait loop in ‘receive-message’.
    
    * src/cuirass/remote.scm (receive-message): Simplify ‘wait’ loop.
---
 src/cuirass/remote.scm | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/cuirass/remote.scm b/src/cuirass/remote.scm
index 0188596..0f89d98 100644
--- a/src/cuirass/remote.scm
+++ b/src/cuirass/remote.scm
@@ -436,21 +436,21 @@ unspecified value when reading a message without payload.
 When ROUTER? is true, assume messages received start with a routing
 prefix (the identity of the peer, as a bytevector), and return three values:
 the payload, the peer's identity (a bytevector), and the peer address."
-  (define (wait)
-    ;; Events are edge-triggered so before waiting, check whether there are
-    ;; messages available.  See the discussion at
-    ;; <https://lists.zeromq.org/pipermail/zeromq-dev/2016-May/030349.html>.
-    (when (zero? (logand ZMQ_POLLIN
-                         (zmq-get-socket-option socket ZMQ_EVENTS)))
-      ((current-read-waiter) (zmq-socket->port socket))
+  (let ((port (zmq-socket->port socket)))
+    (let wait ()
+      ;; Events are edge-triggered so before waiting, check whether there are
+      ;; messages available.  See the discussion at
+      ;; <https://lists.zeromq.org/pipermail/zeromq-dev/2016-May/030349.html>.
       (when (zero? (logand ZMQ_POLLIN
                            (zmq-get-socket-option socket ZMQ_EVENTS)))
+        ((current-read-waiter) port)
+
+        ;; ZMQ_POLLIN might still be clear after epoll(2) has returned.
         ;; Per <http://api.zeromq.org/master:zmq-getsockopt>, "applications
         ;; should simply ignore this case and restart their polling
         ;; operation/event loop."
         (wait))))
 
-  (wait)
   (if router?
       (match (zmq-message-receive* socket)
         ((sender (= zmq-message-size 0) data)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]