Source-Changes-HG archive

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

[src/trunk]: src/tests/fs/nfs/nfsservice make this work with the new fdset st...



details:   https://anonhg.NetBSD.org/src/rev/45a004e89381
branches:  trunk
changeset: 341486:45a004e89381
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Nov 08 02:45:16 2015 +0000

description:
make this work with the new fdset stuff.

diffstat:

 tests/fs/nfs/nfsservice/mountd.c               |   6 +-
 tests/fs/nfs/nfsservice/rpcbind/pmap_svc.c     |  14 +++---
 tests/fs/nfs/nfsservice/rpcbind/rpcb_svc_com.c |  49 ++++++++++++++-----------
 tests/fs/nfs/nfsservice/rpcbind/rpcbind.c      |   7 ++-
 tests/fs/nfs/nfsservice/rumpnfsd.c             |   5 +-
 5 files changed, 44 insertions(+), 37 deletions(-)

diffs (243 lines):

diff -r ea9ca76efac1 -r 45a004e89381 tests/fs/nfs/nfsservice/mountd.c
--- a/tests/fs/nfs/nfsservice/mountd.c  Sun Nov 08 02:20:26 2015 +0000
+++ b/tests/fs/nfs/nfsservice/mountd.c  Sun Nov 08 02:45:16 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mountd.c,v 1.9 2015/08/21 14:19:10 christos Exp $       */
+/*     $NetBSD: mountd.c,v 1.10 2015/11/08 02:45:16 christos Exp $      */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char     sccsid[] = "@(#)mountd.c  8.15 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mountd.c,v 1.9 2015/08/21 14:19:10 christos Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.10 2015/11/08 02:45:16 christos Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -353,7 +353,7 @@
        extern sem_t gensem;
        pthread_t ptdummy;
 
-       alloc_fdset();
+       svc_fdset_init(SVC_FDSET_MT | SVC_FDSET_POLL);
 
 #if 0
        while ((c = getopt(argc, argv, "dNnrp:" ADDOPTS)) != -1)
diff -r ea9ca76efac1 -r 45a004e89381 tests/fs/nfs/nfsservice/rpcbind/pmap_svc.c
--- a/tests/fs/nfs/nfsservice/rpcbind/pmap_svc.c        Sun Nov 08 02:20:26 2015 +0000
+++ b/tests/fs/nfs/nfsservice/rpcbind/pmap_svc.c        Sun Nov 08 02:45:16 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_svc.c,v 1.2 2013/10/19 17:45:00 christos Exp $    */
+/*     $NetBSD: pmap_svc.c,v 1.3 2015/11/08 02:45:16 christos Exp $    */
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -173,18 +173,18 @@
        struct sockcred *sc;
        char uidbuf[32];
 
+
+       if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (char *)&reg)) {
+               svcerr_decode(xprt);
+               return (FALSE);
+       }
+
 #ifdef RPCBIND_DEBUG
        if (debugging)
                fprintf(stderr, "%s request for (%lu, %lu) : ",
                    op == PMAPPROC_SET ? "PMAP_SET" : "PMAP_UNSET",
                    reg.pm_prog, reg.pm_vers);
 #endif
-
-       if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (char *)&reg)) {
-               svcerr_decode(xprt);
-               return (FALSE);
-       }
-
        if (!check_access(xprt, op, &reg, PMAPVERS)) {
                svcerr_weakauth(xprt);
                return FALSE;
diff -r ea9ca76efac1 -r 45a004e89381 tests/fs/nfs/nfsservice/rpcbind/rpcb_svc_com.c
--- a/tests/fs/nfs/nfsservice/rpcbind/rpcb_svc_com.c    Sun Nov 08 02:20:26 2015 +0000
+++ b/tests/fs/nfs/nfsservice/rpcbind/rpcb_svc_com.c    Sun Nov 08 02:45:16 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpcb_svc_com.c,v 1.2 2011/09/16 16:13:18 plunky Exp $  */
+/*     $NetBSD: rpcb_svc_com.c,v 1.3 2015/11/08 02:45:16 christos Exp $        */
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -291,7 +291,7 @@
 delete_prog(int prog)
 {
        RPCB reg;
-       register rpcblist_ptr rbl;
+       rpcblist_ptr rbl;
 
        for (rbl = list_rbl; rbl != NULL; rbl = rbl->rpcb_next) {
                if ((rbl->rpcb_map.r_prog != prog))
@@ -514,10 +514,7 @@
                rmttail->next = rmt;
                rmttail = rmt;
        }
-       /* XXX not threadsafe */
-       if (fd > *get_fdsetmax())
-               *get_fdsetmax() = fd;
-       FD_SET(fd, get_fdset());
+       svc_fdset_set(fd);
        return (fd);
 }
 
@@ -590,7 +587,7 @@
 rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp,
                    rpcproc_t reply_type, rpcvers_t versnum)
 {
-       register rpcblist_ptr rbl;
+       rpcblist_ptr rbl;
        struct netconfig *nconf;
        struct netbuf *caller;
        struct r_rmtcall_args a;
@@ -1024,8 +1021,8 @@
        if (fi->flag & FINFO_ACTIVE) {
                netbuffree(fi->caller_addr);
                /* XXX may be too big, but can't access xprt array here */
-               if (fi->forward_fd >= *get_fdsetmax())
-                       (*get_fdsetmax())--;
+               if (fi->forward_fd >= *svc_fdset_getmax())
+                       (*svc_fdset_getmax())--;
                free((void *) fi->uaddr);
                fi->flag &= ~FINFO_ACTIVE;
                rpcb_rmtcalls--;
@@ -1065,22 +1062,30 @@
 extern bool_t __svc_clean_idle(fd_set *, int, bool_t);
 
 void
-my_svc_run()
+my_svc_run(void)
 {
        size_t nfds;
-       struct pollfd pollfds[FD_SETSIZE];
+       struct pollfd *pollfds = NULL;
+       int npollfds = 0;
        int poll_ret, check_ret;
-       int n;
+       int n, m;
 #ifdef SVC_RUN_DEBUG
        int i;
 #endif
-       register struct pollfd  *p;
-       fd_set cleanfds;
+       struct pollfd   *p;
+       fd_set *cleanfds = NULL;
 
        for (;;) {
+               if (svc_fdset_getsize(0) != npollfds) {
+                       npollfds = svc_fdset_getsize(0);
+                       pollfds = realloc(pollfds, npollfds * sizeof(*pollfds));
+                       free(cleanfds);
+                       cleanfds = svc_fdset_copy(svc_fdset_get());
+               }
                p = pollfds;
-               for (n = 0; n <= *get_fdsetmax(); n++) {
-                       if (FD_ISSET(n, get_fdset())) {
+               m = *svc_fdset_getmax();
+               for (n = 0; n <= m; n++) {
+                       if (svc_fdset_isset(n)) {
                                p->fd = n;
                                p->events = MASKVAL;
                                p++;
@@ -1107,8 +1112,7 @@
                         * other outside event) and not caused by poll().
                         */
                case 0:
-                       cleanfds = *get_fdset();
-                       __svc_clean_idle(&cleanfds, 30, FALSE);
+                       __svc_clean_idle(cleanfds, 30, FALSE);
                        continue;
                default:
 #ifdef SVC_RUN_DEBUG
@@ -1134,7 +1138,8 @@
                }
 #ifdef SVC_RUN_DEBUG
                if (debugging) {
-                       fprintf(stderr, "svc_maxfd now %u\n", *get_fdsetmax());
+                       fprintf(stderr, "svc_maxfd now %u\n",
+                           *svc_fdset_getmax());
                }
 #endif
        }
@@ -1292,7 +1297,7 @@
 static void
 find_versions(rpcprog_t prog, char *netid, rpcvers_t *lowvp, rpcvers_t *highvp)
 {
-       register rpcblist_ptr rbl;
+       rpcblist_ptr rbl;
        int lowv = 0;
        int highv = 0;
 
@@ -1329,8 +1334,8 @@
 static rpcblist_ptr
 find_service(rpcprog_t prog, rpcvers_t vers, char *netid)
 {
-       register rpcblist_ptr hit = NULL;
-       register rpcblist_ptr rbl;
+       rpcblist_ptr hit = NULL;
+       rpcblist_ptr rbl;
 
        for (rbl = list_rbl; rbl != NULL; rbl = rbl->rpcb_next) {
                if ((rbl->rpcb_map.r_prog != prog) ||
diff -r ea9ca76efac1 -r 45a004e89381 tests/fs/nfs/nfsservice/rpcbind/rpcbind.c
--- a/tests/fs/nfs/nfsservice/rpcbind/rpcbind.c Sun Nov 08 02:20:26 2015 +0000
+++ b/tests/fs/nfs/nfsservice/rpcbind/rpcbind.c Sun Nov 08 02:45:16 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpcbind.c,v 1.5 2015/08/21 14:19:10 christos Exp $     */
+/*     $NetBSD: rpcbind.c,v 1.6 2015/11/08 02:45:16 christos Exp $     */
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -130,7 +130,7 @@
        parseargs(argc, argv);
 #endif
 
-       alloc_fdset();
+       svc_fdset_init(SVC_FDSET_MT);
 
        getrlimit(RLIMIT_NOFILE, &rl);
        if (rl.rlim_cur < 128) {
@@ -343,7 +343,8 @@
                nb.buf = sa;
                nb.len = nb.maxlen = sa->sa_len;
                uaddr = taddr2uaddr(nconf, &nb);
-               (void)fprintf(stderr, "rpcbind: my address is %s\n", uaddr);
+               (void)fprintf(stderr, "rpcbind: my address is %s fd=%d\n",
+                   uaddr, fd);
                (void)free(uaddr);
        }
 #endif
diff -r ea9ca76efac1 -r 45a004e89381 tests/fs/nfs/nfsservice/rumpnfsd.c
--- a/tests/fs/nfs/nfsservice/rumpnfsd.c        Sun Nov 08 02:20:26 2015 +0000
+++ b/tests/fs/nfs/nfsservice/rumpnfsd.c        Sun Nov 08 02:45:16 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpnfsd.c,v 1.8 2014/05/12 15:31:07 christos Exp $    */
+/*     $NetBSD: rumpnfsd.c,v 1.9 2015/11/08 02:45:16 christos Exp $    */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -37,6 +37,7 @@
 #include <string.h>
 #include <syslog.h>
 #include <unistd.h>
+#include <rpc/rpc.h>
 
 void *mountd_main(void *);
 void *rpcbind_main(void *);
@@ -87,7 +88,7 @@
        }
 
        rump_init();
-       init_fdsets();
+       svc_fdset_init(SVC_FDSET_MT);
 
        rv = rump_pub_etfs_register("/etc/exports", "./exports", RUMP_ETFS_REG);
        if (rv) {



Home | Main Index | Thread Index | Old Index