diff src/lib/network.c @ 3537:5ff3b88db948 HEAD

net_listen(): Print bind() errors only if it's not EADDRINUSE. Also do the same for listen().
author Timo Sirainen <tss@iki.fi>
date Mon, 15 Aug 2005 02:19:29 +0300
parents d1ed3b3548db
children 0b6539bc22b9
line wrap: on
line diff
--- a/src/lib/network.c	Mon Aug 15 01:30:55 2005 +0300
+++ b/src/lib/network.c	Mon Aug 15 02:19:29 2005 +0300
@@ -293,9 +293,12 @@
 #endif
 	/* specify the address/port we want to listen in */
 	ret = bind(fd, &so.sa, SIZEOF_SOCKADDR(so));
-	if (ret < 0)
-		i_error("bind(%s) failed: %m", net_ip2addr(my_ip));
-	else {
+	if (ret < 0) {
+		if (errno != EADDRINUSE) {
+			i_error("bind(%s, %u) failed: %m",
+				net_ip2addr(my_ip), *port);
+		}
+	} else {
 		/* get the actual port we started listen */
 		len = SIZEOF_SOCKADDR(so);
 		ret = getsockname(fd, &so.sa, &len);
@@ -304,7 +307,10 @@
 
 			/* start listening */
 			if (listen(fd, backlog) >= 0)
-                                return fd;
+				return fd;
+
+			if (errno != EADDRINUSE)
+				i_error("listen() failed: %m");
 		}
 	}