svn rev #21647: branches/mskrb-integ/src/kadmin/server/

lhoward@MIT.EDU lhoward at MIT.EDU
Wed Dec 31 20:23:24 EST 2008


http://src.mit.edu/fisheye/changelog/krb5/?cs=21647
Commit By: lhoward
Log Message:
Don't add a socket to sstate.rfds until add_XXX_fd() has returned
successfully, as otherwise it will contain a dangling FD reference



Changed Files:
U   branches/mskrb-integ/src/kadmin/server/network.c
Modified: branches/mskrb-integ/src/kadmin/server/network.c
===================================================================
--- branches/mskrb-integ/src/kadmin/server/network.c	2009-01-01 00:39:10 UTC (rev 21646)
+++ branches/mskrb-integ/src/kadmin/server/network.c	2009-01-01 01:23:23 UTC (rev 21647)
@@ -436,14 +436,16 @@
 
     conn->u.rpc.transp = svctcp_create(sock, 0, 0);
     if (conn->u.rpc.transp == NULL) {
-	krb5_klog_syslog(LOG_ERR, "Cannot create RPC service, continuing.");
+	krb5_klog_syslog(LOG_ERR, "Cannot create RPC service: %s; continuing",
+			 strerror(errno));
 	delete_fd(conn);
 	return NULL;
     }
 
     if (!svc_register(conn->u.rpc.transp, svc->prognum, svc->versnum,
 		      svc->dispatch, IPPROTO_TCP)) {
-	krb5_klog_syslog(LOG_ERR, "Cannot register RPC service, continuing.");
+	krb5_klog_syslog(LOG_ERR, "Cannot register RPC service: %s; continuing",
+			 strerror(errno));
 	delete_fd(conn);
 	return NULL;
     }
@@ -629,26 +631,28 @@
 
 	/* Sockets are created, prepare to listen on them.  */
 	if (s4 >= 0) {
-	    FD_SET(s4, &sstate.rfds);
-	    if (s4 >= sstate.max)
-		sstate.max = s4 + 1;
-	    if (add_tcp_listener_fd(data, s4) == 0)
+	    if (add_tcp_listener_fd(data, s4) == NULL)
 		close(s4);
-	    else
+	    else {
+		FD_SET(s4, &sstate.rfds);
+		if (s4 >= sstate.max)
+		    sstate.max = s4 + 1;
 		krb5_klog_syslog(LOG_INFO, "listening on fd %d: tcp %s",
 				 s4, paddr((struct sockaddr *)&sin4));
+	    }
 	}
 #ifdef KRB5_USE_INET6
 	if (s6 >= 0) {
-	    FD_SET(s6, &sstate.rfds);
-	    if (s6 >= sstate.max)
-		sstate.max = s6 + 1;
-	    if (add_tcp_listener_fd(data, s6) == 0) {
+	    if (add_tcp_listener_fd(data, s6) == NULL) {
 		close(s6);
 		s6 = -1;
-	    } else
+	    } else {
+		FD_SET(s6, &sstate.rfds);
+		if (s6 >= sstate.max)
+		    sstate.max = s6 + 1;
 		krb5_klog_syslog(LOG_INFO, "listening on fd %d: tcp %s",
 				 s6, paddr((struct sockaddr *)&sin6));
+	    }
 	    if (s4 < 0)
 		krb5_klog_syslog(LOG_INFO,
 				 "assuming IPv6 socket accepts IPv4");
@@ -680,14 +684,15 @@
 	if (s4 < 0)
 	    return -1;
 	else {
-	    FD_SET(s4, &sstate.rfds);
-	    if (s4 >= sstate.max)
-		sstate.max = s4 + 1;
-	    if (add_rpc_listener_fd(data, &svc, s4) == 0)
+	    if (add_rpc_listener_fd(data, &svc, s4) == NULL)
 		close(s4);
-	    else
+	    else {
+		FD_SET(s4, &sstate.rfds);
+		if (s4 >= sstate.max)
+		    sstate.max = s4 + 1;
 		krb5_klog_syslog(LOG_INFO, "listening on fd %d: rpc %s",
 				 s4, paddr((struct sockaddr *)&sin4));
+	    }
 	}
     }
     FD_ZERO(&rpc_listenfds);
@@ -804,9 +809,6 @@
 		return 1;
 	    }
 	}
-	FD_SET (sock, &sstate.rfds);
-	if (sock >= sstate.max)
-	    sstate.max = sock + 1;
 	krb5_klog_syslog (LOG_INFO, "listening on fd %d: udp %s%s", sock,
 			  paddr((struct sockaddr *)addr),
 			  pktinfo ? " (pktinfo)" : "");
@@ -814,6 +816,9 @@
 	    close(sock);
 	    return 1;
 	}
+	FD_SET (sock, &sstate.rfds);
+	if (sock >= sstate.max)
+	    sstate.max = sock + 1;
     }
     return 0;
 }




More information about the cvs-krb5 mailing list