zloop timer event return code overwritten by poller #113

Closed
sgundry opened this Issue Jan 13, 2013 · 5 comments

Projects

None yet

3 participants

@sgundry
sgundry commented Jan 13, 2013

During the main zloop, the timer return code "rc" will be overwritten by poller return codes. See "rc" set at line 372 but is then overwritten at line 414.

This means it is possible for a timer's cancel (rc=-1) to be lost.

It's not the easiest code to test deterministically. I have written a small program that floods a poller and the timer is indeed ignored/written over. I can upload this if need be but the bug is easily identified reading the code: rc is not checked between a timer return and the poller return.

I've posted to zmq-dev but this might be the more logical place.

Thanks,
Sam

@hintjens hintjens added a commit to hintjens/czmq that referenced this issue Jan 13, 2013
@hintjens hintjens Fixed issue #113 96b8cb1
@hintjens
Member

Fixed it, I think. Waiting for a maintainer to merge the pull request: #112

@sgundry
sgundry commented Jan 23, 2013

Thanks and sorry for the late reply.

This doesn't work as rc is used for zmq_poll() return values too. So rc > 0 when there is something for a pollitem but the for loop won't run if rc != 0. Running ./czmq_selftest loops forever.

My working code just checks for if( rc >= 0 ) for() {}. I'll submit a pull request.

Sam.

Edit: I can't clone from github at work unfortunately.

-for (item_nbr = 0; item_nbr < self->poll_size && rc == 0; item_nbr++) {
+for (item_nbr = 0; item_nbr < self->poll_size && rc >= 0; item_nbr++) {

@hintjens
Member

Sorry for the poor patch, I was in a hurry. Looking forward to the pull
request,

On Thu, Jan 24, 2013 at 12:04 AM, sgundry notifications@github.com wrote:

Thanks and sorry for the late reply.

This doesn't work as rc is used for zmq_poll() return values too. So rc >
0 when there is something for a pollitem but the for loop won't run if rc
!= 0. Running ./czmq_selftest loops forever.

My working code just checks for if( rc >= 0 ) for() {}. I'll submit a pull
request.

Sam.


Reply to this email directly or view it on GitHubhttps://github.com/zeromq/czmq/issues/113#issuecomment-12627879.

@sgundry sgundry pushed a commit to sgundry/czmq that referenced this issue Jan 27, 2013
unknown Fixed issue #113. 9d66b90
@felipecruz
Member

I think we can close this issue by now, right?

@hintjens
Member
hintjens commented Apr 3, 2013

:-) Yup

@hintjens hintjens closed this Apr 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment