From c2e115dc43fd08682996f215c2e655471c6b39a7 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 10 Dec 2010 19:40:29 +0000 Subject: improved error output on bind error git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@50 e61f0598-a718-4e21-a8f0-0aadfa62ad6b --- src/listener.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/listener.c b/src/listener.c index 69833b7..0c0415e 100644 --- a/src/listener.c +++ b/src/listener.c @@ -162,9 +162,11 @@ static int activate_listener(listener_t* l) log_printf(WARNING, "failed to set IPV6_V6ONLY socket option: %s", strerror(errno)); } + char* ls = tcp_endpoint_to_string(l->local_end_); ret = bind(l->fd_, (struct sockaddr *)&(l->local_end_.addr_), l->local_end_.len_); if(ret) { - log_printf(ERROR, "Error on bind(): %s", strerror(errno)); + log_printf(ERROR, "Error on bind(%s): %s", ls ? ls:"", strerror(errno)); + if(ls) free(ls); l->state_ = ZOMBIE; return -1; } @@ -172,13 +174,13 @@ static int activate_listener(listener_t* l) ret = listen(l->fd_, 0); if(ret) { log_printf(ERROR, "Error on listen(): %s", strerror(errno)); + if(ls) free(ls); l->state_ = ZOMBIE; return -1; } l->state_ = ACTIVE; - char* ls = tcp_endpoint_to_string(l->local_end_); char* rs = tcp_endpoint_to_string(l->remote_end_); char* ss = tcp_endpoint_to_string(l->source_end_); log_printf(NOTICE, "listening on: %s (remote: %s%s%s)", ls ? ls:"(null)", rs ? rs:"(null)", ss ? " with source " : "", ss ? ss : ""); -- cgit v1.2.3