[zeromq-dev] Handling errors from OpenPGM call pgm_recv() and friends

Martin Sustrik sustrik at 250bpm.com
Fri Dec 18 14:28:04 CET 2009


Hi Steven,

Thanks for exhaustive info on the errors. I've fixed the memory leaks 
(GIT rev. 86d68cb), however, proper error handling is still to be done.

Actually, there are two different cases in 0MQ.

One of them is opening of PGM transport which is done synchronously and 
the error can be returned to the user via API. As 0MQ API uses errnos to 
report errors, so we should write a function that converts PGM error 
codes into appropriate errnos.

The second case is when error occurs when sending/receiving data. This 
is done asynchronously and the error should be handled in the background 
instead of passing it to the user. In this case there are only two 
different error types to take into account: those that should never 
happen (indicates bug in the code) and those that can happen due to 
different problems with the network. The former we'll handle usign 
assers, the latter can be handled by [delayed] reinitialisation of PGM 
transport.

Martin

Steven McCoy wrote:
> Finally,
> 
>         const PGMIOStatus status = pgm_recvmsgv (transport, pgm_msgv,
>             pgm_msgv_len, MSG_DONTWAIT, &nbytes_rec, &pgm_error);
> 
> and
> 
>     PGMIOStatus status = pgm_recvmsgv (transport, &dummy_msg,
>         1, MSG_DONTWAIT, &dummy_bytes, &pgm_error);
> 
> Similarly have memory leaks on failure.
> 
> If the PGMIOStatus return value is PGM_IO_STATUS_RESET you can see a
> mesage from PGM_RECV_ERROR domain,
> 
> 	PGM_RECV_ERROR_CONNRESET
> 		Transport has been reset on unrecoverable loss from %s.
> 
> NB:  Set the MSG_ERRQUEUE flag to withold the generation of the error text.
> 
> 
> If the PGMIOStatus return value is PGM_IO_STATUS_ERROR the GError may
> be set to the following from the PGM_RECV_ERROR domain, recvmsg(2),
> select(2), poll(2) derived errors,
> 
> 	EBADF          -> PGM_RECV_ERROR_BADF
> 	EFAULT         -> PGM_RECV_ERROR_FAULT
> 	EINTR          -> PGM_RECV_ERROR_INTR
> 	EINVAL         -> PGM_RECV_ERROR_INVAL
> 	ENOMEM         -> PGM_RECV_ERROR_NOMEM
> 	*              -> PGM_RECV_ERROR_FAILED   /* catch all */
> 
> 	WSAEINVAL      -> PGM_RECV_ERROR_INVAL
> 	WSAEMFILE      -> PGM_RECV_ERROR_MFILE
> 	WSA_NOT_ENOUGH_MEMORY -> PGM_RECV_ERROR_NOMEM
> 	WSAENOPROTOOPT -> PGM_RECV_ERROR_NOPROTOOPT
> 	WSAECONNRESET  -> PGM_RECV_ERROR_CONNRESET
> 	*              -> PGM_RECV_ERROR_FAILED   /* catch all */
> 
> 		Transport socket error: %s
> 		Waiting for event: %s
> 




More information about the zeromq-dev mailing list