From owner-svn-src-stable@FreeBSD.ORG Thu Mar 3 19:57:50 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 632AC1065781; Thu, 3 Mar 2011 19:57:50 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 381468FC18; Thu, 3 Mar 2011 19:57:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p23Jvovm068425; Thu, 3 Mar 2011 19:57:50 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p23JvonL068423; Thu, 3 Mar 2011 19:57:50 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201103031957.p23JvonL068423@svn.freebsd.org> From: John Baldwin Date: Thu, 3 Mar 2011 19:57:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r219249 - stable/7/usr.sbin/nfsd X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Mar 2011 19:57:50 -0000 Author: jhb Date: Thu Mar 3 19:57:49 2011 New Revision: 219249 URL: http://svn.freebsd.org/changeset/base/219249 Log: MFC 218777: Save a copy of errno before invoking syslog() if accept() or select() fail. syslog() can trash the errno value causing nfsd to exit for non-fatal errors like ECONNABORTED from accept(). Modified: stable/7/usr.sbin/nfsd/nfsd.c Directory Properties: stable/7/usr.sbin/nfsd/ (props changed) Modified: stable/7/usr.sbin/nfsd/nfsd.c ============================================================================== --- stable/7/usr.sbin/nfsd/nfsd.c Thu Mar 3 19:57:38 2011 (r219248) +++ stable/7/usr.sbin/nfsd/nfsd.c Thu Mar 3 19:57:49 2011 (r219249) @@ -128,7 +128,7 @@ main(int argc, char **argv) socklen_t len; int on = 1, unregister, reregister, sock; int tcp6sock, ip6flag, tcpflag, tcpsock; - int udpflag, ecode, s, srvcnt; + int udpflag, ecode, error, s, srvcnt; int bindhostc, bindanyflag, rpcbreg, rpcbregcnt; char **bindhost = NULL; pid_t pid; @@ -652,8 +652,9 @@ main(int argc, char **argv) if (connect_type_cnt > 1) { if (select(maxsock + 1, &ready, NULL, NULL, NULL) < 1) { + error = errno; syslog(LOG_ERR, "select failed: %m"); - if (errno == EINTR) + if (error == EINTR) continue; nfsd_exit(1); } @@ -664,9 +665,10 @@ main(int argc, char **argv) len = sizeof(inetpeer); if ((msgsock = accept(tcpsock, (struct sockaddr *)&inetpeer, &len)) < 0) { + error = errno; syslog(LOG_ERR, "accept failed: %m"); - if (errno == ECONNABORTED || - errno == EINTR) + if (error == ECONNABORTED || + error == EINTR) continue; nfsd_exit(1); } @@ -686,10 +688,11 @@ main(int argc, char **argv) if ((msgsock = accept(tcpsock, (struct sockaddr *)&inet6peer, &len)) < 0) { + error = errno; syslog(LOG_ERR, "accept failed: %m"); - if (errno == ECONNABORTED || - errno == EINTR) + if (error == ECONNABORTED || + error == EINTR) continue; nfsd_exit(1); }