[zeromq-dev] Mac OS X: test_shutdown_stress sometimes fails
Christian Gudrian
christian at gudrian.org
Fri Nov 12 12:00:47 CET 2010
Am 12.11.2010 11:34, schrieb Christian Gudrian:
> Is there any reasonable way to appropriately handle this condition?
What about something like this:
diff --git a/src/mailbox.cpp b/src/mailbox.cpp
index c186007..3cf8640 100644
--- a/src/mailbox.cpp
+++ b/src/mailbox.cpp
@@ -73,7 +73,14 @@ void zmq::mailbox_t::send (const command_t &cmd_)
// TODO: Implement SNDBUF auto-resizing as for POSIX platforms.
// In the mean time, the following code with assert if the send()
// call would block.
- int nbytes = ::send (w, (char *)&cmd_, sizeof (command_t), 0);
+ int nbytes;
+ while (true)
+ {
+ nbytes = ::send (w, (char *)&cmd_, sizeof (command_t), 0);
+ if ((nbytes == SOCKET_ERROR) && (GetLastError () == WSAEWOULDBLOCK))
+ Sleep (1);
+ break;
+ }
wsa_assert (nbytes != SOCKET_ERROR);
zmq_assert (nbytes == sizeof (command_t));
}
Christian
More information about the zeromq-dev
mailing list