diff options
author | jhb <jhb@FreeBSD.org> | 2011-02-17 17:03:56 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2011-02-17 17:03:56 +0000 |
commit | 6c8422154a358569181d069417e56eb7a3a1c6c8 (patch) | |
tree | 29582e79abc90ba548a20a6b1104d20a55b79723 /usr.sbin/nfsd/nfsd.c | |
parent | 38ea23ab3eb9b2ae741939f14f4dd1d81e531110 (diff) | |
download | FreeBSD-src-6c8422154a358569181d069417e56eb7a3a1c6c8.zip FreeBSD-src-6c8422154a358569181d069417e56eb7a3a1c6c8.tar.gz |
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().
MFC after: 1 week
Diffstat (limited to 'usr.sbin/nfsd/nfsd.c')
-rw-r--r-- | usr.sbin/nfsd/nfsd.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c index d86309f..364045d 100644 --- a/usr.sbin/nfsd/nfsd.c +++ b/usr.sbin/nfsd/nfsd.c @@ -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); } |