summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2010-12-10 19:40:29 +0000
committerChristian Pointner <equinox@spreadspace.org>2010-12-10 19:40:29 +0000
commitc2e115dc43fd08682996f215c2e655471c6b39a7 (patch)
tree7b195b8b5ef32a945e8efb77fddcac1d6323c29f
parentupdated initscript (sig-hup -> reload) (diff)
improved error output on bind error
git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@50 e61f0598-a718-4e21-a8f0-0aadfa62ad6b
-rw-r--r--src/listener.c6
1 files 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 : "");