Date: Thu, 3 Mar 2011 19:57:38 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r219248 - stable/8/usr.sbin/nfsd Message-ID: <201103031957.p23Jvct3068361@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Thu Mar 3 19:57:38 2011 New Revision: 219248 URL: http://svn.freebsd.org/changeset/base/219248 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/8/usr.sbin/nfsd/nfsd.c Directory Properties: stable/8/usr.sbin/nfsd/ (props changed) Modified: stable/8/usr.sbin/nfsd/nfsd.c ============================================================================== --- stable/8/usr.sbin/nfsd/nfsd.c Thu Mar 3 19:55:22 2011 (r219247) +++ stable/8/usr.sbin/nfsd/nfsd.c Thu Mar 3 19:57:38 2011 (r219248) @@ -134,7 +134,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; int stablefd, nfssvc_addsock; char **bindhost = NULL; @@ -738,8 +738,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); } @@ -750,9 +751,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); } @@ -772,10 +774,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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103031957.p23Jvct3068361>