[zeromq-dev] Handling errors from OpenPGM call pgm_recv() and friends
Martin Sustrik
sustrik at 250bpm.com
Mon Dec 21 18:57:39 CET 2009
Hi Steven,
I've modified the code in the following way:
// Bind a transport to the specified network devices.
if (!pgm_transport_bind (transport, &pgm_error)) {
if (pgm_error->code == PGM_IF_ERROR_INVAL ||
pgm_error->code == PGM_IF_ERROR_XDEV ||
pgm_error->code == PGM_IF_ERROR_NODEV ||
pgm_error->code == PGM_IF_ERROR_NOTUNIQ ||
pgm_error->code == PGM_IF_ERROR_ADDRFAMILY ||
pgm_error->code == PGM_IF_ERROR_FAMILY ||
pgm_error->code == PGM_IF_ERROR_NODATA ||
pgm_error->code == PGM_IF_ERROR_NONAME ||
pgm_error->code == PGM_IF_ERROR_SERVICE) {
g_error_free (pgm_error);
errno = EINVAL;
return -1;
}
zmq_assert (false);
}
The idea is that the problems caused by user are reported as EINVAL. If
there'll be need for more fine grained errors we can then map OpenPGM
errors to errnos, as required by concrete scenarios.
The errors not caused by the user result in an assertion. If these occur
in practice, we can either add the code to handle the error decently
(say by restarting the transport) or return adequate errno.
Does the code look right? I was not sure about the "domain" in the error.
Martin
More information about the zeromq-dev
mailing list