[zeromq-dev] Mac OS X: test_shutdown_stress sometimes fails

Martin Sustrik sustrik at 250bpm.com
Sat Nov 13 08:35:56 CET 2010


Christian,
> 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));
>   }
>    
Even easier way to accomplish the above would be to use blocking send. 
That was how the code looked like formerly. However, it can lead to 
deadlocks. Thus, the only way the handle the problem is to increase the 
send buffer to accomodate the command.

Martin



More information about the zeromq-dev mailing list