Module Name: src Committed By: christos Date: Sun Nov 8 02:45:16 UTC 2015
Modified Files: src/tests/fs/nfs/nfsservice: mountd.c rumpnfsd.c src/tests/fs/nfs/nfsservice/rpcbind: pmap_svc.c rpcb_svc_com.c rpcbind.c Log Message: make this work with the new fdset stuff. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/fs/nfs/nfsservice/mountd.c cvs rdiff -u -r1.8 -r1.9 src/tests/fs/nfs/nfsservice/rumpnfsd.c cvs rdiff -u -r1.2 -r1.3 src/tests/fs/nfs/nfsservice/rpcbind/pmap_svc.c \ src/tests/fs/nfs/nfsservice/rpcbind/rpcb_svc_com.c cvs rdiff -u -r1.5 -r1.6 src/tests/fs/nfs/nfsservice/rpcbind/rpcbind.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/fs/nfs/nfsservice/mountd.c diff -u src/tests/fs/nfs/nfsservice/mountd.c:1.9 src/tests/fs/nfs/nfsservice/mountd.c:1.10 --- src/tests/fs/nfs/nfsservice/mountd.c:1.9 Fri Aug 21 10:19:10 2015 +++ src/tests/fs/nfs/nfsservice/mountd.c Sat Nov 7 21:45:16 2015 @@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19 #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 @@ mountd_main(void *arg) 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) Index: src/tests/fs/nfs/nfsservice/rumpnfsd.c diff -u src/tests/fs/nfs/nfsservice/rumpnfsd.c:1.8 src/tests/fs/nfs/nfsservice/rumpnfsd.c:1.9 --- src/tests/fs/nfs/nfsservice/rumpnfsd.c:1.8 Mon May 12 11:31:07 2014 +++ src/tests/fs/nfs/nfsservice/rumpnfsd.c Sat Nov 7 21:45:16 2015 @@ -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 @@ main(int argc, char *argv[]) } rump_init(); - init_fdsets(); + svc_fdset_init(SVC_FDSET_MT); rv = rump_pub_etfs_register("/etc/exports", "./exports", RUMP_ETFS_REG); if (rv) { Index: src/tests/fs/nfs/nfsservice/rpcbind/pmap_svc.c diff -u src/tests/fs/nfs/nfsservice/rpcbind/pmap_svc.c:1.2 src/tests/fs/nfs/nfsservice/rpcbind/pmap_svc.c:1.3 --- src/tests/fs/nfs/nfsservice/rpcbind/pmap_svc.c:1.2 Sat Oct 19 13:45:00 2013 +++ src/tests/fs/nfs/nfsservice/rpcbind/pmap_svc.c Sat Nov 7 21:45:16 2015 @@ -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 @@ pmapproc_change(struct svc_req *rqstp, S struct sockcred *sc; char uidbuf[32]; -#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 *)®)) { 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 (!check_access(xprt, op, ®, PMAPVERS)) { svcerr_weakauth(xprt); return FALSE; Index: src/tests/fs/nfs/nfsservice/rpcbind/rpcb_svc_com.c diff -u src/tests/fs/nfs/nfsservice/rpcbind/rpcb_svc_com.c:1.2 src/tests/fs/nfs/nfsservice/rpcbind/rpcb_svc_com.c:1.3 --- src/tests/fs/nfs/nfsservice/rpcbind/rpcb_svc_com.c:1.2 Fri Sep 16 12:13:18 2011 +++ src/tests/fs/nfs/nfsservice/rpcbind/rpcb_svc_com.c Sat Nov 7 21:45:16 2015 @@ -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 @@ void 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 @@ create_rmtcall_fd(struct netconfig *ncon 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 @@ void 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 @@ free_slot_by_index(int idx) 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 @@ netbuffree(struct netbuf *ap) 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 @@ my_svc_run() * 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 @@ my_svc_run() } #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 @@ done: 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 @@ find_versions(rpcprog_t prog, char *neti 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) || Index: src/tests/fs/nfs/nfsservice/rpcbind/rpcbind.c diff -u src/tests/fs/nfs/nfsservice/rpcbind/rpcbind.c:1.5 src/tests/fs/nfs/nfsservice/rpcbind/rpcbind.c:1.6 --- src/tests/fs/nfs/nfsservice/rpcbind/rpcbind.c:1.5 Fri Aug 21 10:19:10 2015 +++ src/tests/fs/nfs/nfsservice/rpcbind/rpcbind.c Sat Nov 7 21:45:16 2015 @@ -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 @@ rpcbind_main(void *arg) 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 @@ init_transport(struct netconfig *nconf) 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