summaryrefslogtreecommitdiff
path: root/src/socket_base.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2010-02-19 15:25:05 +0100
committerMartin Sustrik <sustrik@250bpm.com>2010-02-19 15:25:05 +0100
commitaff1f6621ae13083c7f15f7f1f808560254a2dcb (patch)
tree9e73dd8bd5d38a21e0aa83b4d4bea55b7792b39e /src/socket_base.cpp
parent75f571c8844231f4172f131e1dd6ba2348eb54e5 (diff)
parent2a79a943de417679c562cd4a917e1d1bc19b0d25 (diff)
Merge branch 'master' of git@github.com:sustrik/zeromq2
Diffstat (limited to 'src/socket_base.cpp')
-rw-r--r--src/socket_base.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/socket_base.cpp b/src/socket_base.cpp
index 1607673..871f9e9 100644
--- a/src/socket_base.cpp
+++ b/src/socket_base.cpp
@@ -346,6 +346,7 @@ int zmq::socket_base_t::recv (::zmq_msg_t *msg_, int flags_)
{
// Get the message.
int rc = xrecv (msg_, flags_);
+ int err = errno;
// Once every inbound_poll_rate messages check for signals and process
// incoming commands. This happens only if we are not polling altogether
@@ -364,29 +365,30 @@ int zmq::socket_base_t::recv (::zmq_msg_t *msg_, int flags_)
if (rc == 0)
return 0;
+ // If we don't have the message, restore the original cause of the problem.
+ errno = err;
+
// If the message cannot be fetched immediately, there are two scenarios.
// For non-blocking recv, commands are processed in case there's a revive
// command already waiting int a command pipe. If it's not, return EAGAIN.
- // In blocking scenario, commands are processed over and over again until
- // we are able to fetch a message.
if (flags_ & ZMQ_NOBLOCK) {
if (errno != EAGAIN)
return -1;
app_thread->process_commands (false, false);
- rc = xrecv (msg_, flags_);
ticks = 0;
- }
- else {
- while (rc != 0) {
- if (errno != EAGAIN)
- return -1;
- app_thread->process_commands (true, false);
- rc = xrecv (msg_, flags_);
- ticks = 0;
- }
+ return xrecv (msg_, flags_);
}
- return rc;
+ // In blocking scenario, commands are processed over and over again until
+ // we are able to fetch a message.
+ while (rc != 0) {
+ if (errno != EAGAIN)
+ return -1;
+ app_thread->process_commands (true, false);
+ rc = xrecv (msg_, flags_);
+ ticks = 0;
+ }
+ return 0;
}
int zmq::socket_base_t::close ()