I assert that I can hang the server below from another application:

--8<--------------------------------------------------
#include <zmq.h>
#include <iostream>

int main(int argc, char* argv[] )
{
        void* context = zmq_init( 1 );
        void* publisher = zmq_socket( context, ZMQ_PUB );
        void* frontend = zmq_socket( context, ZMQ_PULL );
        zmq_bind( publisher, "tcp://*:5555" );
        zmq_bind( frontend, "tcp://*:5556" );

        DWORD lastHeartbeatTime = ::GetTickCount();
        zmq_msg_t msg;          

        while( true )
        {
                zmq_pollitem_t items [] = 
                {
                        { frontend, 0, ZMQ_POLLIN, 0 }
                };
                zmq_poll( &items[0], 1, 100 );

                if( items [0].revents & ZMQ_POLLIN )
                {
                        zmq_msg_init( &msg );
                        zmq_recvmsg( frontend, &msg, 0);
                        std::cout << "got request\n";
                        zmq_msg_close( &msg );
                }
                DWORD current = ::GetTickCount();
                if( ( current - lastHeartbeatTime ) > 1000 )
                {
                        lastHeartbeatTime = current;
                        std::cout << "send out heartbeat\n";
                        zmq_msg_init_size( &msg, 16 );
                        memset( zmq_msg_data( &msg ), 0, 16 );
                        zmq_sendmsg( publisher, &msg, 0 );  // HANGS
HERE
                        zmq_msg_close( &msg );
                }
        }
}
--8<--------------------------------------------------


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Chuck Remes
Sent: Wednesday, November 02, 2011 8:58 PM
To: ZeroMQ development list
Subject: Re: [zeromq-dev] FW: zmq hangs

On Nov 2, 2011, at 12:44 PM, Alexander Altshuler wrote:

> 
> On Nov 2, 2011, at 8:29 PM, Chuck Remes wrote:
>> It should be very simple to reproduce.
>> Can you write a small C program that shows this behavior?
> 
> I spent a day trying to reproduce this hang with some simple code, but
> without success. When I back-ported this code to zeromq 2.1 - it works
> fine.
> 
> Client application is closed-source. I may provide only binary.
> But server is very simple. I can provide the source code.
> All work on Win32 platform.

Explain how you backported the application from 3.02 to 2.1.x. Perhaps
during the backport you fixed the bug.

The "backport" should have only been replacing zmq_sendmsg() with
zmq_send(). If you made any other changes, they might be the fix.

Lastly, it is unlikely anyone wants to run your application and this
binary on their system to debug the problem for free. :)

cr

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to