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

Steven McCoy steven.mccoy at miru.hk
Fri Dec 18 05:04:06 CET 2009


Hi Hi,

  I noticed the 0MQ code updating but a lot of the error handling not
implemented yet, first

http://github.com/sustrik/zeromq2/blob/master/src/pgm_socket.cpp

    if (!pgm_if_get_transport_info (network, NULL, &res, &pgm_error)) {
        errno = EINVAL;
        return -1;
    }

Is a memory leak, the GError object needs to be freed:

    if (!pgm_if_get_transport_info (network, NULL, &res, &pgm_error)) {
        errno = EINVAL;
	g_error_free (pgm_error);
        return -1;
    }

I see a lot of these comments,

        //  TODO: tranlate errors from glib into errnos.

To translate the error messages, consider the following, GError
consists of a domain, error code, and error message, the
pgm_if_get_transport_info() only returns error codes from the
PGM_IF_ERROR domain, these are described below.

Format is,

	(error code)
		(error message)

Multiple message values may appear for the same error code.

	PGM_IF_ERROR_INVAL
		'%c" is not a valid character.
		Send group list contains more than one entity.
		Unresolvable receive group: %s
		
	PGM_IF_ERROR_XDEV
		Expecting network interface address, found IPv4 multicast network: %s
		Expecting network interface address, found IPv6 multicast network: %s
		Expecting interface address, found IPv4 multicast address: %s
		Expecting interface address, found IPv6 multicast address: %s
		Network name resolves to IPv4 mulicast address: %s
		Network name resolves to IPv6 mulicast address: %s

	PGM_IF_ERROR_NODEV
		IP address family conflict when resolving network name \"%s\", found
AF_INET when AF_INET6 expected.
		IP address family conflict when resolving network name \"%s\", found
AF_INET6 when AF_INET expected.
		IP address class conflict when resolving network name \"%s\",
expected IPv6 multicast.
		Not configured for IPv6 network name support, \"%s\" is an IPv6 network name.
		Network name resolves to non-internet protocol address family: \"%s\"
		No matching network interface: %s

	PGM_IF_ERROR_NOTUNIQ
		Network interface name not unique: %s

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 */

An eai_errno value of EAI_SYSTEM means that a generic system error
might occur.  The following system errno values are handled,

	EFAULT         -> PGM_IF_ERROR_FAULT
	EINVAL         -> PGM_IF_ERROR_INVAL
	EPERM          -> PGM_IF_ERROR_PERM
	*              -> PGM_IF_ERROR_FAILED	/* catch all */

		Numeric host resolution: %s
		Internet host resolution: %s
		Resolving receive group: %s

getifaddrs() errors derived from errno set for any of the errors
specified for socket(2), bind(2), getsockname(2), recvmsg(2),
sendto(2), malloc(3), or realloc(3).

Emulated getifaddrs() errors will be derived from errno set for any of
socket(2) or ioctl(2) on Unix, on Windows errno will be invalid but
failure will be due to GetAdapterAddresses() failing on
ERROR_ADDRESS_NOT_ASSOCIATED, ERROR_NOT_ENOUGH_MEMORY, or
ERROR_NO_DATA.

		Enumerating network interfaces: %s


The following prefixes may appear on error messsages,

		Node primary address family cannot be determined:
		Unique address cannot be determined for interface \"%s\":
		Unresolvable receive entity \"%s\":
		Unresolvable send entity \"%s\":

All the PGM_IF_ERROR_* values will exist on all platforms, however
there are no guarantees all the errno or eai_errno values will.

-- 
Steve-o



More information about the zeromq-dev mailing list