[zeromq-dev] [zmqpp] Handling of EINTR
Lindley French
lindleyf at gmail.com
Mon Jan 13 18:45:44 CET 2014
My zmqpp code has ended up completely littered with clauses like:
bool gotit = false;
try
{
gotit = ts.receive(clientId_str,msgin);
}
catch (zmqpp::zmq_internal_exception e)
{
if (e.zmq_error() != EINTR)
{
throw;
}
}
This is messy, and clearly not ideal because a class type with "internal"
in the name shouldn't be necessary for the library user.
So let's think for a minute. The purpose of EINTR is to ensure blocking
calls can't prevent signal handling from working properly. It isn't really
an exceptional condition, so is an exception the appropriate way to handle
it? (I'm of the opinion that, unlike Java, exceptions in C++ should
normally be reserved for things going seriously wrong.)
The two places this occurs are poller::poll() and socket::receive(). Both
of these already return bool. Perhaps we can simply return false in the
event if EINTR, instead of throwing? At the very least, this makes sense
for the non-blocking version of receive().
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140113/e5d7e637/attachment.htm>
More information about the zeromq-dev
mailing list