Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/nfsd Don't exit if we have udp only sockets, instea...



details:   https://anonhg.NetBSD.org/src/rev/71ded42f7a53
branches:  trunk
changeset: 817526:71ded42f7a53
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Aug 23 13:10:12 2016 +0000

description:
Don't exit if we have udp only sockets, instead wait for all the workers
to terminate.

diffstat:

 usr.sbin/nfsd/nfsd.c |  23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diffs (68 lines):

diff -r e7ff3d6f25be -r 71ded42f7a53 usr.sbin/nfsd/nfsd.c
--- a/usr.sbin/nfsd/nfsd.c      Tue Aug 23 11:03:52 2016 +0000
+++ b/usr.sbin/nfsd/nfsd.c      Tue Aug 23 13:10:12 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfsd.c,v 1.67 2016/08/22 16:08:51 christos Exp $       */
+/*     $NetBSD: nfsd.c,v 1.68 2016/08/23 13:10: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.67 2016/08/22 16:08:51 christos Exp $");
+__RCSID("$NetBSD: nfsd.c,v 1.68 2016/08/23 13:10:12 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -425,6 +425,7 @@
        int ip6flag, ip4flag;
        int s, compat;
        int parent_fd = -1;
+       pthread_t *workers;
 
 #define        DEFNFSDCNT       4
        nfsdcnt = DEFNFSDCNT;
@@ -517,11 +518,16 @@
                tryconf(&cfg[i], i, reregister);
        }
 
+       workers = calloc(nfsdcnt, sizeof(*workers));
+       if (workers == NULL) {
+               logit(LOG_ERR, "thread alloc %s", strerror(errno));
+               exit(1);
+       }
+
        for (i = 0; i < nfsdcnt; i++) {
-               pthread_t t;
                int error;
 
-               error = pthread_create(&t, NULL, worker, NULL);
+               error = pthread_create(&workers[i], NULL, worker, NULL);
                if (error) {
                        errno = error;
                        logit(LOG_ERR, "pthread_create: %s", strerror(errno));
@@ -544,9 +550,6 @@
 
        }
 
-       if (connect_type_cnt == 0)
-               exit(0);
-
        pthread_setname_np(pthread_self(), "master", NULL);
 
        if (debug == 0) {
@@ -557,6 +560,12 @@
                (void)signal(SIGSYS, nonfs);
        }
 
+       if (connect_type_cnt == 0) {
+               for (i = 0; i < nfsdcnt; i++)
+                           pthread_join(workers[i], NULL);
+               exit(0);
+       }
+
        /*
         * Loop forever accepting connections and passing the sockets
         * into the kernel for the mounts.



Home | Main Index | Thread Index | Old Index