Module Name:    src
Committed By:   christos
Date:           Mon Dec 21 05:06:55 UTC 2009

Modified Files:
        src/usr.sbin/nfsd: nfsd.c

Log Message:
PR/42486: Ed Ravin nfsd sometimes exits prematurely during port-scan fix
from freebsd bin 61084 applied (preserving errno properly). The accept
code should be merged.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.sbin/nfsd/nfsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/nfsd/nfsd.c
diff -u src/usr.sbin/nfsd/nfsd.c:1.56 src/usr.sbin/nfsd/nfsd.c:1.57
--- src/usr.sbin/nfsd/nfsd.c:1.56	Fri Nov 21 02:48:35 2008
+++ src/usr.sbin/nfsd/nfsd.c	Mon Dec 21 00:06:55 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfsd.c,v 1.56 2008/11/21 07:48:35 pooka Exp $	*/
+/*	$NetBSD: nfsd.c,v 1.57 2009/12/21 05:06:55 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1994
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)nfsd.c	8.9 (Berkeley) 3/29/95";
 #else
-__RCSID("$NetBSD: nfsd.c,v 1.56 2008/11/21 07:48:35 pooka Exp $");
+__RCSID("$NetBSD: nfsd.c,v 1.57 2009/12/21 05:06:55 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -147,7 +147,7 @@
 	struct sockaddr_in6 inet6peer;
 	struct pollfd set[4];
 	socklen_t len;
-	int ch, cltpflag, connect_type_cnt, i, maxsock, msgsock;
+	int ch, cltpflag, connect_type_cnt, i, maxsock, msgsock, serrno;
 	int nfsdcnt, on = 1, reregister, sock, tcpflag, tcpsock;
 	int tcp6sock, ip6flag;
 	int tp4cnt, tp4flag, tpipcnt, tpipflag, udpflag, ecode, s;
@@ -486,7 +486,10 @@
 			len = sizeof(inetpeer);
 			if ((msgsock = accept(tcpsock,
 			    (struct sockaddr *)&inetpeer, &len)) < 0) {
+				serrno = errno;
 				syslog(LOG_ERR, "accept failed: %m");
+				if (serrno == EINTR || serrno == ECONNABORTED)
+					continue;
 				exit(1);
 			}
 			memset(inetpeer.sin_zero, 0, sizeof(inetpeer.sin_zero));
@@ -505,7 +508,10 @@
 			len = sizeof(inet6peer);
 			if ((msgsock = accept(tcp6sock,
 			    (struct sockaddr *)&inet6peer, &len)) < 0) {
+				serrno = errno;
 				syslog(LOG_ERR, "accept failed: %m");
+				if (serrno == EINTR || serrno == ECONNABORTED)
+					continue;
 				exit(1);
 			}
 			if (setsockopt(msgsock, SOL_SOCKET,
@@ -524,7 +530,10 @@
 			len = sizeof(isopeer);
 			if ((msgsock = accept(tp4sock,
 			    (struct sockaddr *)&isopeer, &len)) < 0) {
+				serrno = errno;
 				syslog(LOG_ERR, "accept failed: %m");
+				if (serrno == EINTR || serrno == ECONNABORTED)
+					continue;
 				exit(1);
 			}
 			if (setsockopt(msgsock, SOL_SOCKET,
@@ -542,7 +551,10 @@
 			len = sizeof(inetpeer);
 			if ((msgsock = accept(tpipsock,
 			    (struct sockaddr *)&inetpeer, &len)) < 0) {
+				serrno = errno;
 				syslog(LOG_ERR, "accept failed: %m");
+				if (serrno == EINTR || serrno == ECONNABORTED)
+					continue;
 				exit(1);
 			}
 			if (setsockopt(msgsock, SOL_SOCKET,

Reply via email to