diff options
author | Martin Lucina <mato@kotelna.sk> | 2010-09-08 15:25:45 +0200 |
---|---|---|
committer | Martin Lucina <martin@lucina.net> | 2012-01-23 08:53:27 +0100 |
commit | 90d73cba9cd1d1724f38ed82fc0eefb1781c9c20 (patch) | |
tree | 1760872164a93384d1adb90db9c8d41777dbb2a7 /src/signaler.cpp | |
parent | cf026feae205bfeb7e007f6afd0e8d7b283865c8 (diff) | |
parent | 5ba1cb20fe6f6699cef1cc726718e760cd4c9af1 (diff) |
Imported Debian patch 2.0.9.dfsg-1debian/2.0.9.dfsg-1
Diffstat (limited to 'src/signaler.cpp')
-rw-r--r-- | src/signaler.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/signaler.cpp b/src/signaler.cpp index 592688b..d4a9214 100644 --- a/src/signaler.cpp +++ b/src/signaler.cpp @@ -176,12 +176,15 @@ zmq::signaler_t::~signaler_t () void zmq::signaler_t::send (const command_t &cmd_) { - ssize_t nbytes = send (w, &cmd_, sizeof (command_t), 0); + ssize_t nbytes; + do { + nbytes = ::send (w, &cmd_, sizeof (command_t), 0); + } while (nbytes == -1 && errno == EINTR); errno_assert (nbytes != -1); zmq_assert (nbytes == sizeof (command_t)); } -bool zmq::signaler_t::recv (command_t &cmd_, bool block_) +bool zmq::signaler_t::recv (command_t *cmd_, bool block_) { if (block_) { @@ -194,7 +197,10 @@ bool zmq::signaler_t::recv (command_t &cmd_, bool block_) } bool result; - ssize_t nbytes = recv (r, buffer, sizeof (command_t), 0); + ssize_t nbytes; + do { + nbytes = ::recv (r, (char*) cmd_, sizeof (command_t), 0); + } while (nbytes == -1 && errno == EINTR); if (nbytes == -1 && errno == EAGAIN) { result = false; } @@ -207,7 +213,7 @@ bool zmq::signaler_t::recv (command_t &cmd_, bool block_) result = true; } - if (block_) + if (block_) { // Set the reader to non-blocking mode. int flags = fcntl (r, F_GETFL, 0); @@ -249,7 +255,10 @@ void zmq::signaler_t::send (const command_t &cmd_) { // TODO: Note that send is a blocking operation. // How should we behave if the command cannot be written to the signaler? - ssize_t nbytes = ::send (w, &cmd_, sizeof (command_t), 0); + ssize_t nbytes; + do { + nbytes = ::send (w, &cmd_, sizeof (command_t), 0); + } while (nbytes == -1 && errno == EINTR); errno_assert (nbytes != -1); // This should never happen as we've already checked that command size is @@ -259,8 +268,11 @@ void zmq::signaler_t::send (const command_t &cmd_) bool zmq::signaler_t::recv (command_t *cmd_, bool block_) { - ssize_t nbytes = ::recv (r, cmd_, sizeof (command_t), - block_ ? 0 : MSG_DONTWAIT); + ssize_t nbytes; + do { + nbytes = ::recv (r, cmd_, sizeof (command_t), + block_ ? 0 : MSG_DONTWAIT); + } while (nbytes == -1 && errno == EINTR); // If there's no signal available return false. if (nbytes == -1 && errno == EAGAIN) |