Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/nfsd Revert previous, don't write to the parent too...
details: https://anonhg.NetBSD.org/src/rev/3d57502bb0ad
branches: trunk
changeset: 944075:3d57502bb0ad
user: christos <christos%NetBSD.org@localhost>
date: Thu Sep 17 12:48:12 2020 +0000
description:
Revert previous, don't write to the parent too early because it can exit
before the child is ready to serve. The child will write in daemon2_detach()
when it is ready.
While here:
- return EXIT_{SUCCESS,FAILURE)
- check syscall error against -1
diffstat:
usr.sbin/nfsd/nfsd.c | 39 +++++++++++++++++++--------------------
1 files changed, 19 insertions(+), 20 deletions(-)
diffs (157 lines):
diff -r 2fc299d18d7c -r 3d57502bb0ad usr.sbin/nfsd/nfsd.c
--- a/usr.sbin/nfsd/nfsd.c Thu Sep 17 11:56:35 2020 +0000
+++ b/usr.sbin/nfsd/nfsd.c Thu Sep 17 12:48:12 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nfsd.c,v 1.72 2020/08/26 13:35:12 gson Exp $ */
+/* $NetBSD: nfsd.c,v 1.73 2020/09/17 12:48:12 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.72 2020/08/26 13:35:12 gson Exp $");
+__RCSID("$NetBSD: nfsd.c,v 1.73 2020/09/17 12:48:12 christos Exp $");
#endif
#endif /* not lint */
@@ -128,10 +128,10 @@
pthread_setname_np(pthread_self(), "slave", NULL);
nfssvc_flag = NFSSVC_NFSD;
memset(&nsd, 0, sizeof(nsd));
- while (nfssvc(nfssvc_flag, &nsd) < 0) {
+ while (nfssvc(nfssvc_flag, &nsd) == -1) {
if (errno != ENEEDAUTH) {
logit(LOG_ERR, "nfssvc: %s", strerror(errno));
- exit(1);
+ exit(EXIT_FAILURE);
}
nfssvc_flag = NFSSVC_NFSD | NFSSVC_AUTHINFAIL;
}
@@ -262,7 +262,7 @@
nfsdargs.sock = sock;
nfsdargs.name = NULL;
nfsdargs.namelen = 0;
- if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) {
+ if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) == -1) {
logit(LOG_ERR, "can't add %s socket: %s",
cfg_netconf[p], strerror(errno));
goto out;
@@ -308,7 +308,7 @@
*/
for (i = 0; i < 3; i++) {
r = pipe2(detach_msg_pipe, O_CLOEXEC|O_NOSIGPIPE);
- if (r < 0)
+ if (r == -1)
return -1;
if (detach_msg_pipe[1] <= STDERR_FILENO &&
(fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
@@ -328,7 +328,6 @@
case 0:
/* child */
(void)close(detach_msg_pipe[0]);
- (void)write(detach_msg_pipe[1], "", 1);
return detach_msg_pipe[1];
default:
break;
@@ -341,14 +340,14 @@
ssize_t nread;
char dummy;
nread = read(detach_msg_pipe[0], &dummy, 1);
- if (nread < 0) {
+ if (nread == -1) {
if (errno == EINTR)
continue;
- _exit(1);
+ _exit(EXIT_FAILURE);
} else if (nread == 0) {
- _exit(1);
+ _exit(EXIT_FAILURE);
} else { /* nread > 0 */
- _exit(0);
+ _exit(EXIT_SUCCESS);
}
}
}
@@ -374,7 +373,7 @@
while (1) {
ssize_t r = write(parentfd, "", 1);
- if (r < 0) {
+ if (r == -1) {
if (errno == EINTR)
continue;
else if (errno == EPIPE)
@@ -441,7 +440,7 @@
ip6flag = 1;
ip4flag = 0;
s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
- if (s < 0 && (errno == EPROTONOSUPPORT ||
+ if (s == -1 && (errno == EPROTONOSUPPORT ||
errno == EPFNOSUPPORT || errno == EAFNOSUPPORT))
ip6flag = 0;
else
@@ -451,7 +450,7 @@
ip6flag = 0;
ip4flag = 1;
s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
- if (s < 0 && (errno == EPROTONOSUPPORT ||
+ if (s == -1 && (errno == EPROTONOSUPPORT ||
errno == EPFNOSUPPORT || errno == EAFNOSUPPORT))
ip4flag = 0;
else
@@ -522,7 +521,7 @@
workers = calloc(nfsdcnt, sizeof(*workers));
if (workers == NULL) {
logit(LOG_ERR, "thread alloc %s", strerror(errno));
- exit(1);
+ exit(EXIT_FAILURE);
}
for (i = 0; i < nfsdcnt; i++) {
@@ -532,7 +531,7 @@
if (error) {
errno = error;
logit(LOG_ERR, "pthread_create: %s", strerror(errno));
- exit(1);
+ exit(EXIT_FAILURE);
}
}
@@ -563,7 +562,7 @@
if (connect_type_cnt == 0) {
for (i = 0; i < nfsdcnt; i++)
pthread_join(workers[i], NULL);
- exit(0);
+ exit(EXIT_SUCCESS);
}
/*
@@ -573,7 +572,7 @@
for (;;) {
if (poll(set, __arraycount(set), INFTIM) == -1) {
logit(LOG_ERR, "poll failed: %s", strerror(errno));
- exit(1);
+ exit(EXIT_FAILURE);
}
for (i = 0; i < __arraycount(set); i++) {
@@ -593,7 +592,7 @@
strerror(errno));
if (serrno == EINTR || serrno == ECONNABORTED)
continue;
- exit(1);
+ exit(EXIT_FAILURE);
}
if (setsockopt(msgsock, SOL_SOCKET, SO_KEEPALIVE, &on,
sizeof(on)) == -1)
@@ -612,7 +611,7 @@
usage(void)
{
(void)fprintf(stderr, "Usage: %s %s\n", getprogname(), USAGE);
- exit(1);
+ exit(EXIT_FAILURE);
}
static void
Home |
Main Index |
Thread Index |
Old Index