[zeromq-dev] possible bug in CZMQ's zloop_start .... with fix

Pieter Hintjens ph at imatix.com
Thu Dec 24 18:18:41 CET 2015


Sounds familiar; be sure to retest on CZMQ master and see it's not
been fixed there. If not, go ahead and send a pull request... :)

On Wed, Dec 23, 2015 at 10:48 PM, Steven Butner <butner.se at gmail.com> wrote:
> I'm running CZMQ version 3.0.1 (though seemingly-identical code appears
> to be present in the newer version also) on an Ubuntu-14.04 LTS system
> running on x64 hardware.  The zloop_start() routine does not terminate
> when a ticket timer handler returns -1, yet the API description for CZMQ
> 3.0.1 says that the zloop_start routine "returns 0 if interrupted, -1 if
> canceled by a handler".
>
> Inspection of the source at zloop.c, line 780 shows that a return of -1
> from a ticket handler does indeed break out from the ticket-handling
> while loop but because the return code (-1, in this case) is not stored
> in "rc", the zloop_start() routine does not actually return.  Instead,
> on my system, it keeps polling.
>
> If I change the code at line 781 to be as below, then zloop_start()
> returns when a ticket timer handler returns -1 and the behavior seems to
> be as advertised in the API documentation.
>
> 775        //  Handle any tickets that have now expired
> 776        s_ticket_t *ticket = (s_ticket_t *) zlistx_first (self->tickets);
> 777        while (ticket && time_now >= ticket->when) {
> 778            if (self->verbose)
> 779                zsys_debug ("zloop: call ticket handler");
> 780            if (ticket->handler (self, 0, ticket->arg) == -1)
> 781               { rc = -1;   break; }     //  Timer handler signaled break
> 782            zlistx_delete (self->tickets, ticket->list_handle);
> 783            ticket = (s_ticket_t *) zlistx_next (self->tickets);
> 784        }
>
> Am I mis-understanding the intended behavior of zloop_start() in this
> case or is this, in fact, a bug?
>
> Thanks ....
>       Steve Butner
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev



More information about the zeromq-dev mailing list