Skip to content
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

Fix rvalue for socket::send() on EHOSTUNREACH #125

Merged
merged 1 commit into from
Jun 7, 2017
Merged

Conversation

msune
Copy link
Contributor

@msune msune commented Jun 7, 2017

@bluca As discussed yesterday in the IRC, I found two issues with C++ example (ROUTER/DEALER loosing msgs [1]):

  1. EHOSTUNREACH was incorrectly handled (something we discussed already). This PR handles this by treating it as other non-terminal errors, like EAGAIN.

  2. I've realised send() with flags ZMQ_DONTWAIT | ZMQ_SNDMORE actually ignores ZMQ_SNDMORE and sends it immediately. This is why the second send in the broker code in the example sent was failing with EHOSTUNREACH exception, as was considering 2nd msg as ZID (I guess) and NULL was an unseen as a ZID yet.

For 2); is this the expected behaviour? I would expect this should either ignore ZMQ_DONTWAIT or give an EINVAL return code. If it's an issue, then it must be a libzmq issue.

Original code of example that triggered the discussion:
[1] https://pastebin.com/AvDEMM1d

===

During introduction of EHOSTUNREACH, missing mapping between
EHOSTUNREACH errno and false/0 return code for socket's send()
calls was missing, throwing an exception.

To be consistent with the rest of wrappers (e.g. DONTWAIT), fix it
by handling this errno as a regular EAGAIN, and let the caller use
errno/zmq_errno() to branch on their code.

During introduction of EHOSTUNREACH, missing mapping between
EHOSTUNREACH errno and false/0 return code for socket's send()
calls was missing, throwing an exception.

To be consistent with the rest of wrappers (e.g. DONTWAIT), fix it
by handling this errno as a regular EAGAIN, and let the caller use
errno/zmq_errno() to branch on their code.
@msune msune changed the title Fix rvalue for scocket::send() on EHOSTUNREACH Fix rvalue for socket::send() on EHOSTUNREACH Jun 7, 2017
@bluca bluca merged commit fc990f1 into zeromq:master Jun 7, 2017
@bluca
Copy link
Member

bluca commented Jun 7, 2017

Thanks!

Regarding the second point, if you check my example: https://pastebin.com/rc6MXN7G
it does use both ZMQ_DONTWAIT | ZMQ_SNDMORE but also here they are just passed through, and both zmq_send and zmq_msg_send as you can see:
https://github.com/zeromq/libzmq/blob/master/src/zmq.cpp#L393
https://github.com/zeromq/libzmq/blob/master/src/zmq.cpp#L635

But here they are just passed through as well:

https://github.com/zeromq/cppzmq/blob/master/zmq.hpp#L627

I really don't understand what's happening :-/

@msune
Copy link
Contributor Author

msune commented Jun 7, 2017

I will try to investigate more on this. We are actually using:

https://github.com/zeromq/cppzmq/blob/master/zmq.hpp#L641

But it's equivalent and should not make any difference.

@msune
Copy link
Contributor Author

msune commented Jun 7, 2017

Quick update;

I'm not able to reproduce 2) anymore. I believe I had some old headers/library lingering around interfering in my sandbox. I will come back if I manage to reproduce it once more.

Thanks

@ax3l ax3l mentioned this pull request Jul 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants