From e37814eca427574578fc53421abea844317222e9 Mon Sep 17 00:00:00 2001 From: Martin Hurton Date: Fri, 6 Jul 2012 13:24:59 +0200 Subject: [PATCH] Rewrite event processing in io_thread --- src/io_thread.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/io_thread.cpp b/src/io_thread.cpp index 40bbef99..b5fe4801 100644 --- a/src/io_thread.cpp +++ b/src/io_thread.cpp @@ -67,20 +67,16 @@ void zmq::io_thread_t::in_event () // TODO: Do we want to limit number of commands I/O thread can // process in a single go? - while (true) { + command_t cmd; + int rc = mailbox.recv (&cmd, 0); - // Get the next command. If there is none, exit. - command_t cmd; - int rc = mailbox.recv (&cmd, 0); - if (rc != 0 && errno == EINTR) - continue; - if (rc != 0 && errno == EAGAIN) - break; - errno_assert (rc == 0); - - // Process the command. - cmd.destination->process_command (cmd); + while (rc == 0 || errno == EINTR) { + if (rc == 0) + cmd.destination->process_command (cmd); + rc = mailbox.recv (&cmd, 0); } + + errno_assert (rc != 0 && errno == EAGAIN); } void zmq::io_thread_t::out_event ()