Fix rvalue for socket::send() on EHOSTUNREACH #125
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@bluca As discussed yesterday in the IRC, I found two issues with C++ example (ROUTER/DEALER loosing msgs [1]):
EHOSTUNREACH
was incorrectly handled (something we discussed already). This PR handles this by treating it as other non-terminal errors, likeEAGAIN
.I've realised
send()
with flagsZMQ_DONTWAIT | ZMQ_SNDMORE
actually ignoresZMQ_SNDMORE
and sends it immediately. This is why the second send in the broker code in the example sent was failing withEHOSTUNREACH
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 anEINVAL
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.