patches for inndstart.c and rc.c

Antonio Querubin tony at lava.net
Sun Mar 31 02:06:23 UTC 2002


Attached are two patches for the CURRENT snapshot.

The patch for inndstart fixes a bug in a call to setsockopt() which
overloaded the variable i as both the socket file descriptor and an option
value.

The second patch is a workaround for a problem where innd is passed 2 file
descriptors, one for IPv6 and the other for IPv4, and both are setup for
listening on any address.  innd will call RCsetup in rc.c which will setup
listening for the first file descriptor but will complain about address
already in use when it attempts to listen using the second file
descriptor.  The workaround ignores the error and foregoes use of the
second file descriptor by returning from RCsetup early instead of stopping
innd.  innd will still accept connections to the IPv4 address through the
first listener.  This behaviour of listen() is probably implementation
specific.


-- Attached file included as plaintext by Ecartis --
-- File: inndstart.c.diff
-- Desc: for innd/inndstart.c in CURRENT snapshot

--- innd/inndstart.c.orig	Sat Mar 30 00:00:39 2002
+++ innd/inndstart.c	Sat Mar 30 14:54:09 2002
@@ -226,8 +226,9 @@
 			    addr->ai_protocol)) < 0)
 		continue; /* ignore */
 #ifdef SO_REUSEADDR
-	    if (setsockopt(i, SOL_SOCKET, SO_REUSEADDR, (char *)&i,
-			sizeof i) < 0)
+	    j = 1;
+	    if (setsockopt(i, SOL_SOCKET, SO_REUSEADDR, (char *)&j,
+			sizeof j) < 0)
 		syswarn("can't set SO_REUSEADDR");
 #endif
 	    if (bind(i, addr->ai_addr, addr->ai_addrlen) < 0) {

-- Attached file included as plaintext by Ecartis --
-- File: rc.c.diff
-- Desc: for innd/rc.c. in CURRENT snapshot

--- innd/rc.c.orig	Sat Mar 30 00:00:40 2002
+++ innd/rc.c	Sat Mar 30 15:36:06 2002
@@ -1930,7 +1930,11 @@
 
     /* Set it up to wait for connections. */
     if (listen(i, MAXLISTEN) < 0) {
+	j = errno;
 	syslog(L_FATAL, "%s cant listen RCreader %m", LogName);
+	/* some IPv6 systems already listening on any address will 
+	   return EADDRINUSE when trying to listen on the IPv4 socket */
+	if ( j = EADDRINUSE ) return -1;
 	exit(1);
     }
 



More information about the inn-bugs mailing list