diff options
author | Markus Armbruster <armbru@redhat.com> | 2012-02-07 15:09:14 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-02-24 09:06:58 -0600 |
commit | 136faa362d2835998a04779696a504147cf410ce (patch) | |
tree | b9aae846daab1540498d77a38281b00780e41c05 | |
parent | ef0c4a0d89ff78bf1d0c257fb3c5613727dd8194 (diff) | |
download | qemu-136faa362d2835998a04779696a504147cf410ce.zip qemu-136faa362d2835998a04779696a504147cf410ce.tar.gz qemu-136faa362d2835998a04779696a504147cf410ce.tar.bz2 |
sockets: Drop sockets_debug debug code
I'm trying to improve this code's error reporting, and the debug code
is getting in my way: it clutters the code, it clobbers errno in
inconvenient places, and it uses the same fprintf() both for error
reporting and debug output in a few places.
Get rid of it. Once decent error reporting is in place, adding back
whatever debug code we need shouldn't be hard.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | qemu-sockets.c | 43 |
1 files changed, 2 insertions, 41 deletions
diff --git a/qemu-sockets.c b/qemu-sockets.c index 61b2247..e6e6c72 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -26,7 +26,6 @@ # define AI_ADDRCONFIG 0 #endif -static int sockets_debug = 0; static const int on=1, off=0; /* used temporarely until all users are converted to QemuOpts */ @@ -101,21 +100,6 @@ const char *inet_strfamily(int family) return "unknown"; } -static void inet_print_addrinfo(const char *tag, struct addrinfo *res) -{ - struct addrinfo *e; - char uaddr[INET6_ADDRSTRLEN+1]; - char uport[33]; - - for (e = res; e != NULL; e = e->ai_next) { - getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen, - uaddr,INET6_ADDRSTRLEN,uport,32, - NI_NUMERICHOST | NI_NUMERICSERV); - fprintf(stderr,"%s: getaddrinfo: family %s, host %s, port %s\n", - tag, inet_strfamily(e->ai_family), uaddr, uport); - } -} - int inet_listen_opts(QemuOpts *opts, int port_offset) { struct addrinfo ai,*res,*e; @@ -153,8 +137,6 @@ int inet_listen_opts(QemuOpts *opts, int port_offset) gai_strerror(rc)); return -1; } - if (sockets_debug) - inet_print_addrinfo(__FUNCTION__, res); /* create socket + bind */ for (e = res; e != NULL; e = e->ai_next) { @@ -179,13 +161,10 @@ int inet_listen_opts(QemuOpts *opts, int port_offset) for (;;) { if (bind(slisten, e->ai_addr, e->ai_addrlen) == 0) { - if (sockets_debug) - fprintf(stderr,"%s: bind(%s,%s,%d): OK\n", __FUNCTION__, - inet_strfamily(e->ai_family), uaddr, inet_getport(e)); goto listen; } try_next = to && (inet_getport(e) <= to + port_offset); - if (!try_next || sockets_debug) + if (!try_next) fprintf(stderr,"%s: bind(%s,%s,%d): %s\n", __FUNCTION__, inet_strfamily(e->ai_family), uaddr, inet_getport(e), strerror(errno)); @@ -249,8 +228,6 @@ int inet_connect_opts(QemuOpts *opts) gai_strerror(rc)); return -1; } - if (sockets_debug) - inet_print_addrinfo(__FUNCTION__, res); for (e = res; e != NULL; e = e->ai_next) { if (getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen, @@ -269,17 +246,13 @@ int inet_connect_opts(QemuOpts *opts) /* connect to peer */ if (connect(sock,e->ai_addr,e->ai_addrlen) < 0) { - if (sockets_debug || NULL == e->ai_next) + if (NULL == e->ai_next) fprintf(stderr, "%s: connect(%s,%s,%s,%s): %s\n", __FUNCTION__, inet_strfamily(e->ai_family), e->ai_canonname, uaddr, uport, strerror(errno)); closesocket(sock); continue; } - if (sockets_debug) - fprintf(stderr, "%s: connect(%s,%s,%s,%s): OK\n", __FUNCTION__, - inet_strfamily(e->ai_family), - e->ai_canonname, uaddr, uport); freeaddrinfo(res); return sock; } @@ -322,10 +295,6 @@ int inet_dgram_opts(QemuOpts *opts) gai_strerror(rc)); return -1; } - if (sockets_debug) { - fprintf(stderr, "%s: peer (%s:%s)\n", __FUNCTION__, addr, port); - inet_print_addrinfo(__FUNCTION__, peer); - } /* lookup local addr */ memset(&ai,0, sizeof(ai)); @@ -346,10 +315,6 @@ int inet_dgram_opts(QemuOpts *opts) gai_strerror(rc)); return -1; } - if (sockets_debug) { - fprintf(stderr, "%s: local (%s:%s)\n", __FUNCTION__, addr, port); - inet_print_addrinfo(__FUNCTION__, local); - } /* create socket */ sock = qemu_socket(peer->ai_family, peer->ai_socktype, peer->ai_protocol); @@ -541,8 +506,6 @@ int unix_listen_opts(QemuOpts *opts) goto err; } - if (sockets_debug) - fprintf(stderr, "bind(unix:%s): OK\n", un.sun_path); return sock; err: @@ -576,8 +539,6 @@ int unix_connect_opts(QemuOpts *opts) return -1; } - if (sockets_debug) - fprintf(stderr, "connect(unix:%s): OK\n", path); return sock; } |