Module Name: src Committed By: christos Date: Tue Mar 5 19:55:23 UTC 2013
Modified Files: src/lib/libc/rpc: bindresvport.c clnt_bcast.c clnt_dg.c clnt_generic.c clnt_vc.c rpc_generic.c rpc_soc.c rpcb_clnt.c svc.c svc_dg.c svc_generic.c svc_run.c svc_vc.c Added Files: src/lib/libc/rpc: svc_fdset.c svc_fdset.h Log Message: make this usable from RUMP To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/lib/libc/rpc/bindresvport.c cvs rdiff -u -r1.24 -r1.25 src/lib/libc/rpc/clnt_bcast.c cvs rdiff -u -r1.26 -r1.27 src/lib/libc/rpc/clnt_dg.c \ src/lib/libc/rpc/rpc_generic.c cvs rdiff -u -r1.28 -r1.29 src/lib/libc/rpc/clnt_generic.c \ src/lib/libc/rpc/svc_vc.c cvs rdiff -u -r1.19 -r1.20 src/lib/libc/rpc/clnt_vc.c cvs rdiff -u -r1.16 -r1.17 src/lib/libc/rpc/rpc_soc.c cvs rdiff -u -r1.27 -r1.28 src/lib/libc/rpc/rpcb_clnt.c cvs rdiff -u -r1.32 -r1.33 src/lib/libc/rpc/svc.c cvs rdiff -u -r1.15 -r1.16 src/lib/libc/rpc/svc_dg.c cvs rdiff -u -r0 -r1.1 src/lib/libc/rpc/svc_fdset.c \ src/lib/libc/rpc/svc_fdset.h cvs rdiff -u -r1.13 -r1.14 src/lib/libc/rpc/svc_generic.c cvs rdiff -u -r1.20 -r1.21 src/lib/libc/rpc/svc_run.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/rpc/bindresvport.c diff -u src/lib/libc/rpc/bindresvport.c:1.23 src/lib/libc/rpc/bindresvport.c:1.24 --- src/lib/libc/rpc/bindresvport.c:1.23 Tue Mar 20 13:14:50 2012 +++ src/lib/libc/rpc/bindresvport.c Tue Mar 5 14:55:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: bindresvport.c,v 1.23 2012/03/20 17:14:50 matt Exp $ */ +/* $NetBSD: bindresvport.c,v 1.24 2013/03/05 19:55:22 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -35,7 +35,7 @@ static char *sccsid = "@(#)bindresvport.c 1.8 88/02/08 SMI"; static char *sccsid = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC"; #else -__RCSID("$NetBSD: bindresvport.c,v 1.23 2012/03/20 17:14:50 matt Exp $"); +__RCSID("$NetBSD: bindresvport.c,v 1.24 2013/03/05 19:55:22 christos Exp $"); #endif #endif @@ -55,6 +55,7 @@ __RCSID("$NetBSD: bindresvport.c,v 1.23 #include <unistd.h> #include <rpc/rpc.h> +#include "svc_fdset.h" #ifdef __weak_alias __weak_alias(bindresvport,_bindresvport) Index: src/lib/libc/rpc/clnt_bcast.c diff -u src/lib/libc/rpc/clnt_bcast.c:1.24 src/lib/libc/rpc/clnt_bcast.c:1.25 --- src/lib/libc/rpc/clnt_bcast.c:1.24 Tue Mar 20 13:14:50 2012 +++ src/lib/libc/rpc/clnt_bcast.c Tue Mar 5 14:55:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: clnt_bcast.c,v 1.24 2012/03/20 17:14:50 matt Exp $ */ +/* $NetBSD: clnt_bcast.c,v 1.25 2013/03/05 19:55:22 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)clnt_bcast.c 1.15 89/04/21 Copyr 1988 Sun Micro"; #else -__RCSID("$NetBSD: clnt_bcast.c,v 1.24 2012/03/20 17:14:50 matt Exp $"); +__RCSID("$NetBSD: clnt_bcast.c,v 1.25 2013/03/05 19:55:22 christos Exp $"); #endif #endif @@ -81,6 +81,7 @@ __RCSID("$NetBSD: clnt_bcast.c,v 1.24 20 #include <string.h> #include "rpc_internal.h" +#include "svc_fdset.h" #define MAXBCAST 20 /* Max no of broadcasting transports */ #define INITTIME 4000 /* Time to wait initially */ Index: src/lib/libc/rpc/clnt_dg.c diff -u src/lib/libc/rpc/clnt_dg.c:1.26 src/lib/libc/rpc/clnt_dg.c:1.27 --- src/lib/libc/rpc/clnt_dg.c:1.26 Tue Mar 20 13:14:50 2012 +++ src/lib/libc/rpc/clnt_dg.c Tue Mar 5 14:55:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: clnt_dg.c,v 1.26 2012/03/20 17:14:50 matt Exp $ */ +/* $NetBSD: clnt_dg.c,v 1.27 2013/03/05 19:55:22 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro"; #else -__RCSID("$NetBSD: clnt_dg.c,v 1.26 2012/03/20 17:14:50 matt Exp $"); +__RCSID("$NetBSD: clnt_dg.c,v 1.27 2013/03/05 19:55:22 christos Exp $"); #endif #endif @@ -62,6 +62,8 @@ __RCSID("$NetBSD: clnt_dg.c,v 1.26 2012/ #include <signal.h> #include <unistd.h> #include <err.h> + +#include "svc_fdset.h" #include "rpc_internal.h" #ifdef __weak_alias @@ -247,8 +249,13 @@ clnt_dg_create( cu->cu_rlen = svcaddr->len; cu->cu_outbuf = &cu->cu_inbuf[recvsz]; /* Other values can also be set through clnt_control() */ +#ifdef RUMP_RPC cu->cu_wait.tv_sec = 15; /* heuristically chosen */ cu->cu_wait.tv_usec = 0; +#else + cu->cu_wait.tv_sec = 0; /* for testing, 10x / second */ + cu->cu_wait.tv_usec = 100000; +#endif cu->cu_total.tv_sec = -1; cu->cu_total.tv_usec = -1; cu->cu_sendsz = sendsz; Index: src/lib/libc/rpc/rpc_generic.c diff -u src/lib/libc/rpc/rpc_generic.c:1.26 src/lib/libc/rpc/rpc_generic.c:1.27 --- src/lib/libc/rpc/rpc_generic.c:1.26 Tue Mar 20 13:14:50 2012 +++ src/lib/libc/rpc/rpc_generic.c Tue Mar 5 14:55:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rpc_generic.c,v 1.26 2012/03/20 17:14:50 matt Exp $ */ +/* $NetBSD: rpc_generic.c,v 1.27 2013/03/05 19:55:22 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -41,7 +41,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: rpc_generic.c,v 1.26 2012/03/20 17:14:50 matt Exp $"); +__RCSID("$NetBSD: rpc_generic.c,v 1.27 2013/03/05 19:55:22 christos Exp $"); #endif #include "namespace.h" @@ -64,6 +64,8 @@ __RCSID("$NetBSD: rpc_generic.c,v 1.26 2 #include <string.h> #include <syslog.h> #include <rpc/nettype.h> + +#include "svc_fdset.h" #include "rpc_internal.h" #ifdef __weak_alias Index: src/lib/libc/rpc/clnt_generic.c diff -u src/lib/libc/rpc/clnt_generic.c:1.28 src/lib/libc/rpc/clnt_generic.c:1.29 --- src/lib/libc/rpc/clnt_generic.c:1.28 Tue Mar 20 13:14:50 2012 +++ src/lib/libc/rpc/clnt_generic.c Tue Mar 5 14:55:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: clnt_generic.c,v 1.28 2012/03/20 17:14:50 matt Exp $ */ +/* $NetBSD: clnt_generic.c,v 1.29 2013/03/05 19:55:22 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)clnt_generic.c 1.32 89/03/16 Copyr 1988 Sun Micro"; #else -__RCSID("$NetBSD: clnt_generic.c,v 1.28 2012/03/20 17:14:50 matt Exp $"); +__RCSID("$NetBSD: clnt_generic.c,v 1.29 2013/03/05 19:55:22 christos Exp $"); #endif #endif @@ -56,6 +56,8 @@ __RCSID("$NetBSD: clnt_generic.c,v 1.28 #include <string.h> #include <stdlib.h> #include <unistd.h> + +#include "svc_fdset.h" #include "rpc_internal.h" #ifdef __weak_alias Index: src/lib/libc/rpc/svc_vc.c diff -u src/lib/libc/rpc/svc_vc.c:1.28 src/lib/libc/rpc/svc_vc.c:1.29 --- src/lib/libc/rpc/svc_vc.c:1.28 Mon Mar 4 12:29:03 2013 +++ src/lib/libc/rpc/svc_vc.c Tue Mar 5 14:55:23 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: svc_vc.c,v 1.28 2013/03/04 17:29:03 christos Exp $ */ +/* $NetBSD: svc_vc.c,v 1.29 2013/03/05 19:55:23 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -35,7 +35,7 @@ static char *sccsid = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro"; static char *sccsid = "@(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC"; #else -__RCSID("$NetBSD: svc_vc.c,v 1.28 2013/03/04 17:29:03 christos Exp $"); +__RCSID("$NetBSD: svc_vc.c,v 1.29 2013/03/05 19:55:23 christos Exp $"); #endif #endif @@ -68,6 +68,7 @@ __RCSID("$NetBSD: svc_vc.c,v 1.28 2013/0 #include <rpc/rpc.h> +#include "svc_fdset.h" #include "rpc_internal.h" #ifdef __weak_alias @@ -326,7 +327,7 @@ again: * running out. */ if (errno == EMFILE || errno == ENFILE) { - cleanfds = svc_fdset; + cleanfds = *get_fdset(); if (__svc_clean_idle(&cleanfds, 0, FALSE)) goto again; } Index: src/lib/libc/rpc/clnt_vc.c diff -u src/lib/libc/rpc/clnt_vc.c:1.19 src/lib/libc/rpc/clnt_vc.c:1.20 --- src/lib/libc/rpc/clnt_vc.c:1.19 Tue Feb 26 11:33:57 2013 +++ src/lib/libc/rpc/clnt_vc.c Tue Mar 5 14:55:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: clnt_vc.c,v 1.19 2013/02/26 16:33:57 christos Exp $ */ +/* $NetBSD: clnt_vc.c,v 1.20 2013/03/05 19:55:22 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -36,7 +36,7 @@ static char *sccsid = "@(#)clnt_tcp.c 1. static char *sccsid = "@(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC"; static char sccsid[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro"; #else -__RCSID("$NetBSD: clnt_vc.c,v 1.19 2013/02/26 16:33:57 christos Exp $"); +__RCSID("$NetBSD: clnt_vc.c,v 1.20 2013/03/05 19:55:22 christos Exp $"); #endif #endif @@ -77,6 +77,7 @@ __RCSID("$NetBSD: clnt_vc.c,v 1.19 2013/ #include <rpc/rpc.h> +#include "svc_fdset.h" #include "rpc_internal.h" #ifdef __weak_alias Index: src/lib/libc/rpc/rpc_soc.c diff -u src/lib/libc/rpc/rpc_soc.c:1.16 src/lib/libc/rpc/rpc_soc.c:1.17 --- src/lib/libc/rpc/rpc_soc.c:1.16 Mon Jun 25 18:32:45 2012 +++ src/lib/libc/rpc/rpc_soc.c Tue Mar 5 14:55:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rpc_soc.c,v 1.16 2012/06/25 22:32:45 abs Exp $ */ +/* $NetBSD: rpc_soc.c,v 1.17 2013/03/05 19:55:22 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro"; #else -__RCSID("$NetBSD: rpc_soc.c,v 1.16 2012/06/25 22:32:45 abs Exp $"); +__RCSID("$NetBSD: rpc_soc.c,v 1.17 2013/03/05 19:55:22 christos Exp $"); #endif #endif @@ -75,6 +75,7 @@ __RCSID("$NetBSD: rpc_soc.c,v 1.16 2012/ #include <syslog.h> #include <unistd.h> +#include "svc_fdset.h" #include "rpc_internal.h" #ifdef __weak_alias Index: src/lib/libc/rpc/rpcb_clnt.c diff -u src/lib/libc/rpc/rpcb_clnt.c:1.27 src/lib/libc/rpc/rpcb_clnt.c:1.28 --- src/lib/libc/rpc/rpcb_clnt.c:1.27 Tue Mar 20 13:14:50 2012 +++ src/lib/libc/rpc/rpcb_clnt.c Tue Mar 5 14:55:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rpcb_clnt.c,v 1.27 2012/03/20 17:14:50 matt Exp $ */ +/* $NetBSD: rpcb_clnt.c,v 1.28 2013/03/05 19:55:22 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)rpcb_clnt.c 1.30 89/06/21 Copyr 1988 Sun Micro"; #else -__RCSID("$NetBSD: rpcb_clnt.c,v 1.27 2012/03/20 17:14:50 matt Exp $"); +__RCSID("$NetBSD: rpcb_clnt.c,v 1.28 2013/03/05 19:55:22 christos Exp $"); #endif #endif @@ -73,6 +73,7 @@ __RCSID("$NetBSD: rpcb_clnt.c,v 1.27 201 #include <syslog.h> #include <unistd.h> +#include "svc_fdset.h" #include "rpc_internal.h" #ifdef __weak_alias Index: src/lib/libc/rpc/svc.c diff -u src/lib/libc/rpc/svc.c:1.32 src/lib/libc/rpc/svc.c:1.33 --- src/lib/libc/rpc/svc.c:1.32 Mon Mar 4 12:29:03 2013 +++ src/lib/libc/rpc/svc.c Tue Mar 5 14:55:23 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: svc.c,v 1.32 2013/03/04 17:29:03 christos Exp $ */ +/* $NetBSD: svc.c,v 1.33 2013/03/05 19:55:23 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -35,7 +35,7 @@ static char *sccsid = "@(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro"; static char *sccsid = "@(#)svc.c 2.4 88/08/11 4.0 RPCSRC"; #else -__RCSID("$NetBSD: svc.c,v 1.32 2013/03/04 17:29:03 christos Exp $"); +__RCSID("$NetBSD: svc.c,v 1.33 2013/03/05 19:55:23 christos Exp $"); #endif #endif @@ -64,6 +64,7 @@ __RCSID("$NetBSD: svc.c,v 1.32 2013/03/0 #include <rpc/pmap_clnt.h> #endif +#include "svc_fdset.h" #include "rpc_internal.h" #ifdef __weak_alias @@ -149,8 +150,8 @@ xprt_register(SVCXPRT *xprt) goto out; } __svc_xports[sock] = xprt; - FD_SET(sock, &svc_fdset); - svc_maxfd = max(svc_maxfd, sock); + FD_SET(sock, get_fdset()); + *get_fdsetmax() = max(*get_fdsetmax(), sock); rwlock_unlock(&svc_fd_lock); return (TRUE); @@ -187,10 +188,11 @@ __xprt_do_unregister(SVCXPRT *xprt, bool rwlock_wrlock(&svc_fd_lock); if ((sock < FD_SETSIZE) && (__svc_xports[sock] == xprt)) { __svc_xports[sock] = NULL; - FD_CLR(sock, &svc_fdset); - if (sock >= svc_maxfd) { - for (svc_maxfd--; svc_maxfd>=0; svc_maxfd--) - if (__svc_xports[svc_maxfd]) + FD_CLR(sock, get_fdset()); + if (sock >= *get_fdsetmax()) { + for ((*get_fdsetmax())--; *get_fdsetmax() >= 0; + (*get_fdsetmax())--) + if (__svc_xports[*get_fdsetmax()]) break; } } @@ -736,7 +738,7 @@ svc_getreq_poll(struct pollfd *pfdp, int */ if (p->revents & POLLNVAL) { rwlock_wrlock(&svc_fd_lock); - FD_CLR(p->fd, &svc_fdset); + FD_CLR(p->fd, get_fdset()); rwlock_unlock(&svc_fd_lock); } else svc_getreq_common(p->fd); Index: src/lib/libc/rpc/svc_dg.c diff -u src/lib/libc/rpc/svc_dg.c:1.15 src/lib/libc/rpc/svc_dg.c:1.16 --- src/lib/libc/rpc/svc_dg.c:1.15 Mon Mar 4 12:29:03 2013 +++ src/lib/libc/rpc/svc_dg.c Tue Mar 5 14:55:23 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: svc_dg.c,v 1.15 2013/03/04 17:29:03 christos Exp $ */ +/* $NetBSD: svc_dg.c,v 1.16 2013/03/05 19:55:23 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -44,7 +44,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: svc_dg.c,v 1.15 2013/03/04 17:29:03 christos Exp $"); +__RCSID("$NetBSD: svc_dg.c,v 1.16 2013/03/05 19:55:23 christos Exp $"); #endif #include "namespace.h" @@ -64,6 +64,7 @@ __RCSID("$NetBSD: svc_dg.c,v 1.15 2013/0 #endif #include <err.h> +#include "svc_fdset.h" #include "rpc_internal.h" #include "svc_dg.h" @@ -149,7 +150,7 @@ svc_dg_create(int fd, u_int sendsize, u_ slen = sizeof ss; if (getsockname(fd, (struct sockaddr *)(void *)&ss, &slen) < 0) - goto outofmem; + goto freedata; xprt->xp_ltaddr.buf = mem_alloc(sizeof (struct sockaddr_storage)); xprt->xp_ltaddr.maxlen = sizeof (struct sockaddr_storage); xprt->xp_ltaddr.len = slen; Index: src/lib/libc/rpc/svc_generic.c diff -u src/lib/libc/rpc/svc_generic.c:1.13 src/lib/libc/rpc/svc_generic.c:1.14 --- src/lib/libc/rpc/svc_generic.c:1.13 Mon Mar 4 12:17:56 2013 +++ src/lib/libc/rpc/svc_generic.c Tue Mar 5 14:55:23 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: svc_generic.c,v 1.13 2013/03/04 17:17:56 christos Exp $ */ +/* $NetBSD: svc_generic.c,v 1.14 2013/03/05 19:55:23 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)svc_generic.c 1.21 89/02/28 Copyr 1988 Sun Micro"; #else -__RCSID("$NetBSD: svc_generic.c,v 1.13 2013/03/04 17:17:56 christos Exp $"); +__RCSID("$NetBSD: svc_generic.c,v 1.14 2013/03/05 19:55:23 christos Exp $"); #endif #endif @@ -63,6 +63,7 @@ __RCSID("$NetBSD: svc_generic.c,v 1.13 2 #include <unistd.h> #include <err.h> +#include "svc_fdset.h" #include "rpc_internal.h" #ifdef __weak_alias Index: src/lib/libc/rpc/svc_run.c diff -u src/lib/libc/rpc/svc_run.c:1.20 src/lib/libc/rpc/svc_run.c:1.21 --- src/lib/libc/rpc/svc_run.c:1.20 Sun Jun 24 11:26:03 2012 +++ src/lib/libc/rpc/svc_run.c Tue Mar 5 14:55:23 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: svc_run.c,v 1.20 2012/06/24 15:26:03 christos Exp $ */ +/* $NetBSD: svc_run.c,v 1.21 2013/03/05 19:55:23 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -35,7 +35,7 @@ static char *sccsid = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro"; static char *sccsid = "@(#)svc_run.c 2.1 88/07/29 4.0 RPCSRC"; #else -__RCSID("$NetBSD: svc_run.c,v 1.20 2012/06/24 15:26:03 christos Exp $"); +__RCSID("$NetBSD: svc_run.c,v 1.21 2013/03/05 19:55:23 christos Exp $"); #endif #endif @@ -53,6 +53,7 @@ __RCSID("$NetBSD: svc_run.c,v 1.20 2012/ #include <rpc/rpc.h> +#include "svc_fdset.h" #include "rpc_internal.h" #ifdef __weak_alias @@ -65,6 +66,10 @@ svc_run(void) { fd_set readfds, cleanfds; struct timeval timeout; + int maxfd; +#ifndef RUMP_RPC + int probs = 0; +#endif #ifdef _REENTRANT extern rwlock_t svc_fd_lock; #endif @@ -74,21 +79,31 @@ svc_run(void) for (;;) { rwlock_rdlock(&svc_fd_lock); - readfds = svc_fdset; - cleanfds = svc_fdset; + readfds = *get_fdset(); + cleanfds = *get_fdset(); + maxfd = *get_fdsetmax(); rwlock_unlock(&svc_fd_lock); - switch (select(svc_maxfd+1, &readfds, NULL, NULL, &timeout)) { + switch (select(maxfd + 1, &readfds, NULL, NULL, &timeout)) { case -1: +#ifndef RUMP_RPC + if ((errno == EINTR || errno == EBADF) && probs < 100) { + probs++; + continue; + } +#endif if (errno == EINTR) { continue; } - warn("svc_run: - select failed"); + warn("%s: select failed", __func__); return; case 0: __svc_clean_idle(&cleanfds, 30, FALSE); continue; default: svc_getreqset(&readfds); +#ifndef RUMP_RPC + probs = 0; +#endif } } } @@ -105,6 +120,6 @@ svc_exit(void) #endif rwlock_wrlock(&svc_fd_lock); - FD_ZERO(&svc_fdset); + FD_ZERO(get_fdset()); rwlock_unlock(&svc_fd_lock); } Added files: Index: src/lib/libc/rpc/svc_fdset.c diff -u /dev/null src/lib/libc/rpc/svc_fdset.c:1.1 --- /dev/null Tue Mar 5 14:55:23 2013 +++ src/lib/libc/rpc/svc_fdset.c Tue Mar 5 14:55:23 2013 @@ -0,0 +1,63 @@ +/* $NetBSD: svc_fdset.c,v 1.1 2013/03/05 19:55:23 christos Exp $ */ + +#include <sys/cdefs.h> +__RCSID("$NetBSD: svc_fdset.c,v 1.1 2013/03/05 19:55:23 christos Exp $"); + +#include <pthread.h> +#include <stdlib.h> +#include <string.h> +#include <sys/select.h> + +#include "svc_fdset.h" + +static pthread_key_t fdsetkey; +static pthread_key_t fdmaxkey; +static fd_set thefdset; +static int thefdmax; + +void +init_fdsets(void) +{ + + pthread_key_create(&fdsetkey, NULL); + pthread_key_create(&fdmaxkey, NULL); +} + +void +alloc_fdset(void) +{ + fd_set *fdsetti; + int *fdmax; + + fdsetti = malloc(sizeof(*fdsetti)); + memset(fdsetti, 0, sizeof(*fdsetti)); + pthread_setspecific(fdsetkey, fdsetti); + + fdmax = malloc(sizeof(*fdmax)); + memset(fdmax, 0, sizeof(*fdmax)); + pthread_setspecific(fdmaxkey, fdmax); +} + +fd_set * +get_fdset(void) +{ + fd_set *rv; + + rv = pthread_getspecific(fdsetkey); + if (rv) + return rv; + else + return &thefdset; +} + +int * +get_fdsetmax(void) +{ + int *rv; + + rv = pthread_getspecific(fdmaxkey); + if (rv) + return rv; + else + return &thefdmax; +} Index: src/lib/libc/rpc/svc_fdset.h diff -u /dev/null src/lib/libc/rpc/svc_fdset.h:1.1 --- /dev/null Tue Mar 5 14:55:23 2013 +++ src/lib/libc/rpc/svc_fdset.h Tue Mar 5 14:55:23 2013 @@ -0,0 +1,30 @@ +/* $NetBSD: svc_fdset.h,v 1.1 2013/03/05 19:55:23 christos Exp $ */ + +#ifndef _LIBC + +void init_fdsets(void); +void alloc_fdset(void); +fd_set *get_fdset(void); +int *get_fdsetmax(void); + +# ifdef RUMP_RPC +# include <rump/rump.h> +# include <rump/rump_syscalls.h> +# undef close +# define close(a) rump_sys_close(a) +# undef fcntl +# define fcntl(a, b, c) rump_sys_fcntl(a, b, c) +# undef read +# define read(a, b, c) rump_sys_read(a, b, c) +# undef write +# define write(a, b, c) rump_sys_write(a, b, c) +# undef pollts +# define pollts(a, b, c, d) rump_sys_pollts(a, b, c, d) +# undef select +# define select(a, b, c, d, e) rump_sys_select(a, b, c, d, e) +# endif + +#else +# define get_fdset() (&svc_fdset) +# define get_fdsetmax() (&svc_maxfd) +#endif