-
Notifications
You must be signed in to change notification settings - Fork 525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem: zloop is using reader callback after zloop_reader_end #1634
Comments
You get a reference to the socket in the callback, can't you simply check if it's still valid and return if not? |
I guess a way to fix this would be to do the same check at https://github.com/zeromq/czmq/blob/master/src/zloop.c#L715 after the timers callbacks and before the pollset is checked at https://github.com/zeromq/czmq/blob/master/src/zloop.c#L770 |
@bluca How would you see checking socket in callback when zloop on pollset rebuild is making copy of reader struct (as far as I can tell from code here https://github.com/zeromq/czmq/blob/master/src/zloop.c#L265)? Something like: |
zmq_poll is edge triggered so skipping and going back into it while there's still data to read would be wrong, since it would not return anymore until new data is available See: https://funcptr.net/2012/09/10/zeromq---edge-triggered-notification/ |
Ok, then this https://github.com/zeromq/czmq/blob/master/src/zloop.c#L795 is also invalid, isn't it? |
It's the ZMQ_FD notification socket that is edge triggered. zmq_poll() can
be used in a level triggered fashion.
zmq_poll() does this by checking ZMQ_EVENTS before doing any poll/select on
the ZMQ_FD.
On 7 Mar 2017 9:08 p.m., "Luca Boccassi" <notifications@github.com> wrote:
zmq_poll is edge triggered so skipping and going back into it while there's
still data to read would be wrong, since it would not return anymore until
new data is available
See: https://funcptr.net/2012/09/10/zeromq---edge-triggered-notification/
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1634 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACiLA1RNXdR_ehZG8kYwsLuaF4XewCvSks5rjVblgaJpZM4MVXRa>
.
|
@piskorzj you are right indeed, got confused for a moment |
Ok :) |
perfect, thanks |
…#1634 Solution: Rebuild pollset after timers if poll needs to be rebuilt.
…#1634 Solution: Rebuild pollset after timers if poll needs to be rebuilt.
Problem: zloop is using reader callback after zloop_reader_end #1634
Fixed by #1635 |
I've recently hit a problem when I have zloop with timer and reader. And inside timer I'm doing zloop_reader_end. All works well until both conditions are met in one zloop go - timer is expired and data is available on reader. In timer after zloop_reader_end I'm also doing zsock_destroy and other cleanup stuff. Thus callback called for socket contains invalid data - I don't want it to be called after doing zloop_reader_end cause it breaks whole loop logic.
Any suggestions how to avoid this or zloop implementation needs to be changed?
The text was updated successfully, but these errors were encountered: