[zeromq-dev] Handling errors from OpenPGM call pgm_transport_bind()

Steven McCoy steven.mccoy at miru.hk
Fri Dec 18 05:42:37 CET 2009


Hi Hi,

    //  Bind a transport to the specified network devices.
    if (!pgm_transport_bind (transport, &pgm_error)) {
        //  TODO: tranlate errors from glib into errnos.
        return -1;
    }

Has a memory leak,

    //  Bind a transport to the specified network devices.
    if (!pgm_transport_bind (transport, &pgm_error)) {
        //  TODO: tranlate errors from glib into errnos.
        g_error_free (pgm_error);
        return -1;
    }

Regarding error translation, all errors are from the
PGM_TRANSPORT_ERROR or PGM_IF_ERROR domain,

Format:
	(error code)
		(error message)


PGM_TRANSPORT_ERROR domain:

eventfd(2), fcntl(2), setsockopt(2), sendto(2) derived errors,

	EFAULT         -> PGM_TRANSPORT_ERROR_FAULT
	EINVAL         -> PGM_TRANSPORT_ERROR_INVAL
	EPERM          -> PGM_TRANSPORT_ERROR_PERM
	EMFILE         -> PGM_TRANSPORT_ERROR_MFILE
	ENFILE         -> PGM_TRANSPORT_ERROR_NFILE
	ENODEV         -> PGM_TRANSPORT_ERROR_NODEV
	ENOMEM         -> PGM_TRANSPORT_ERROR_NOMEM
	ENOPROTOOPT    -> PGM_TRANSPORT_ERROR_NOPROTOOPT
	*              -> PGM_TRANSPORT_ERROR_FAILED   /* catch all */

On Windows a selection of WSA errors are caught,

	WSAEINVAL      -> PGM_TRANSPORT_ERROR_INVAL
	WSAEMFILE      -> PGM_TRANSPORT_ERROR_MFILE
	WSA_NOT_ENOUGH_MEMORY -> PGM_TRANSPORT_ERROR_NOMEM
	WSAENOPROTOOPT -> PGM_TRANSPORT_ERROR_NOPROTOOPT
	WSAECONNRESET  -> PGM_TRANSPORT_ERROR_CONNRESET
	*              -> PGM_TRANSPORT_ERROR_FAILED   /* catch all */

		Creating RDATA notification channel: %s
		Creating waiting peer notification channel: %s
		Enabling reuse of socket local address: %s
		Enabling receipt of ancillary information per incoming packet: %s
		Enabling receipt of control message per incoming datagram: %s
		Enabling IP header in front of user data: %s
		Setting maximum socket receive buffer in bytes: %s		
		Setting maximum socket send buffer in bytes: %s
		Binding receive socket to address %s: %s
		Binding receive socket2 to address %s: %s
		Binding send socket to address %s: %s
		Binding IP Router Alert (RFC 2113) send socket to address %s: %s
		Joining multicast group %s: %s
		Joining multicast group %s on interface %s: %s
		Joining multicast group %s from source %s: %s
		Setting device %s for multicast send socket: %s
		Setting device %s for multicast IP Router Alert (RFC 2113) send socket: %s
		Setting multicast loopback: %s
		Setting multicast hop limit to %i: %s
		Sending SPM broadcast: %s


PGM_IF_ERROR domain:

	PGM_IF_ERROR_NODEV
		No matching network interface index: %i

getaddrinfo() errors derived from eai_errno produce the following:
       EAI_ADDRFAMILY -> PGM_IF_ERROR_ADDRFAMILY
       EAI_AGAIN      -> PGM_IF_ERROR_AGAIN
       EAI_BADFLAGS   -> PGM_IF_ERROR_BADFLAGS
       EAI_FAIL       -> PGM_IF_ERROR_FAIL
       EAI_FAMILY     -> PGM_IF_ERROR_FAMILY
       EAI_MEMORY     -> PGM_IF_ERROR_MEMORY
       EAI_NODATA     -> PGM_IF_ERROR_NODATA
       EAI_NONAME     -> PGM_IF_ERROR_NONAME
       EAI_SERVICE    -> PGM_IF_ERROR_SERVICE
       EAI_SOCKTYPE   -> PGM_IF_ERROR_SOCKTYPE
       *              -> PGM_IF_ERROR_FAILED   /* catch all */

gethostname(2), getifaddrs(3) derived errors and EAI_SYSTEM:
       EFAULT         -> PGM_IF_ERROR_FAULT
       EINVAL         -> PGM_IF_ERROR_INVAL
       EPERM          -> PGM_IF_ERROR_PERM
       *              -> PGM_IF_ERROR_FAILED   /* catch all */

gethostbyname(3) derived errors via h_errno:
       HOST_NOT_FOUND -> PGM_IF_ERROR_NONAME
       TRY_AGAIN      -> PGM_IF_ERROR_AGAIN
       NO_RECOVERY    -> PGM_IF_ERROR_FAIL
       NO_DATA        -> PGM_IF_ERROR_NODATA
       *              -> PGM_IF_ERROR_FAILED   /* catch all */

		Numeric host resolution: %s
		Internet host resolution: %s
		Resolving receive group: %s
		Enumerating network interfaces: %s
		Resolving hostname address: %s
		Resolving hostname address family.
		Resolving IPv4 hostname address: %s
		
-- 
Steve-o



More information about the zeromq-dev mailing list