From 38e5f8699ccff09a91e37e139c4a86a259ac597b Mon Sep 17 00:00:00 2001 From: Paul Colomiets Date: Tue, 17 May 2011 10:12:27 +0200 Subject: Better handling of memory error in resolve_ip_hostname Signed-off-by: Paul Colomiets --- src/ip.cpp | 9 +++++++++ src/zmq_connecter.cpp | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ip.cpp b/src/ip.cpp index 5de2485..c24d92f 100644 --- a/src/ip.cpp +++ b/src/ip.cpp @@ -301,7 +301,16 @@ int zmq::resolve_ip_hostname (sockaddr_storage *addr_, socklen_t *addr_len_, addrinfo *res; int rc = getaddrinfo (hostname.c_str (), service.c_str (), &req, &res); if (rc) { + + switch (rc) { + case EAI_MEMORY: + errno = ENOMEM; + break; + default: errno = EINVAL; + break; + } + return -1; } diff --git a/src/zmq_connecter.cpp b/src/zmq_connecter.cpp index fb77cdc..ca9bb77 100644 --- a/src/zmq_connecter.cpp +++ b/src/zmq_connecter.cpp @@ -45,7 +45,7 @@ zmq::zmq_connecter_t::zmq_connecter_t (class io_thread_t *io_thread_, current_reconnect_ivl(options.reconnect_ivl) { int rc = tcp_connecter.set_address (protocol_, address_); - zmq_assert (rc == 0); + zmq_assert (rc == 0); //TODO: take care ENOMEM, EINVAL } zmq::zmq_connecter_t::~zmq_connecter_t () -- cgit v1.2.3