Home | History | Annotate | Line # | Download | only in rpc
mt_misc.c revision 1.1.6.2
      1  1.1.6.2  nathanw /*	$NetBSD: mt_misc.c,v 1.1.6.2 2001/09/04 02:56:16 nathanw Exp $	*/
      2      1.1     fvdl 
      3      1.1     fvdl /*
      4      1.1     fvdl  *	Define and initialize MT data for libnsl.
      5      1.1     fvdl  *	The _libnsl_lock_init() function below is the library's .init handler.
      6      1.1     fvdl  */
      7      1.1     fvdl 
      8      1.1     fvdl /* #pragma ident	"@(#)mt_misc.c	1.24	93/04/29 SMI" */
      9      1.1     fvdl 
     10      1.1     fvdl #include	"reentrant.h"
     11      1.1     fvdl #include	<rpc/rpc.h>
     12      1.1     fvdl #include	<sys/time.h>
     13      1.1     fvdl #include	<stdlib.h>
     14  1.1.6.2  nathanw #include	<string.h>
     15      1.1     fvdl 
     16  1.1.6.1  nathanw #ifdef _REENTRANT
     17      1.1     fvdl 
     18  1.1.6.1  nathanw /* protects the services list (svc.c) */
     19  1.1.6.1  nathanw rwlock_t	svc_lock = RWLOCK_INITIALIZER;
     20  1.1.6.1  nathanw /* protects svc_fdset and the xports[] array */
     21  1.1.6.1  nathanw rwlock_t	svc_fd_lock = RWLOCK_INITIALIZER;
     22  1.1.6.1  nathanw /* protects the RPCBIND address cache */
     23  1.1.6.1  nathanw rwlock_t	rpcbaddr_cache_lock = RWLOCK_INITIALIZER;
     24  1.1.6.1  nathanw 
     25  1.1.6.1  nathanw /* protects authdes cache (svcauth_des.c) */
     26  1.1.6.1  nathanw mutex_t	authdes_lock = MUTEX_INITIALIZER;
     27  1.1.6.1  nathanw /* auth_none.c serialization */
     28  1.1.6.1  nathanw mutex_t	authnone_lock = MUTEX_INITIALIZER;
     29  1.1.6.1  nathanw /* protects the Auths list (svc_auth.c) */
     30  1.1.6.1  nathanw mutex_t	authsvc_lock = MUTEX_INITIALIZER;
     31  1.1.6.1  nathanw /* protects client-side fd lock array */
     32  1.1.6.1  nathanw mutex_t	clnt_fd_lock = MUTEX_INITIALIZER;
     33  1.1.6.1  nathanw /* clnt_raw.c serialization */
     34  1.1.6.1  nathanw mutex_t	clntraw_lock = MUTEX_INITIALIZER;
     35  1.1.6.1  nathanw /* domainname and domain_fd (getdname.c) and default_domain (rpcdname.c) */
     36  1.1.6.1  nathanw mutex_t	dname_lock = MUTEX_INITIALIZER;
     37  1.1.6.1  nathanw /* dupreq variables (svc_dg.c) */
     38  1.1.6.1  nathanw mutex_t	dupreq_lock = MUTEX_INITIALIZER;
     39  1.1.6.1  nathanw /* protects first_time and hostname (key_call.c) */
     40  1.1.6.1  nathanw mutex_t	keyserv_lock = MUTEX_INITIALIZER;
     41  1.1.6.1  nathanw /* serializes rpc_trace() (rpc_trace.c) */
     42  1.1.6.1  nathanw mutex_t	libnsl_trace_lock = MUTEX_INITIALIZER;
     43  1.1.6.1  nathanw /* loopnconf (rpcb_clnt.c) */
     44  1.1.6.1  nathanw mutex_t	loopnconf_lock = MUTEX_INITIALIZER;
     45  1.1.6.1  nathanw /* serializes ops initializations */
     46  1.1.6.1  nathanw mutex_t	ops_lock = MUTEX_INITIALIZER;
     47  1.1.6.1  nathanw /* protects ``port'' static in bindresvport() */
     48  1.1.6.1  nathanw mutex_t	portnum_lock = MUTEX_INITIALIZER;
     49  1.1.6.1  nathanw /* protects proglst list (svc_simple.c) */
     50  1.1.6.1  nathanw mutex_t	proglst_lock = MUTEX_INITIALIZER;
     51  1.1.6.1  nathanw /* serializes clnt_com_create() (rpc_soc.c) */
     52  1.1.6.1  nathanw mutex_t	rpcsoc_lock = MUTEX_INITIALIZER;
     53  1.1.6.1  nathanw /* svc_raw.c serialization */
     54  1.1.6.1  nathanw mutex_t	svcraw_lock = MUTEX_INITIALIZER;
     55  1.1.6.1  nathanw /* xprtlist (svc_generic.c) */
     56  1.1.6.1  nathanw mutex_t	xprtlist_lock = MUTEX_INITIALIZER;
     57  1.1.6.1  nathanw /* serializes calls to public key routines */
     58  1.1.6.1  nathanw mutex_t serialize_pkey = MUTEX_INITIALIZER;
     59      1.1     fvdl 
     60  1.1.6.1  nathanw #endif /* _REENTRANT */
     61      1.1     fvdl 
     62      1.1     fvdl 
     63  1.1.6.1  nathanw #undef	rpc_createerr
     64      1.1     fvdl 
     65  1.1.6.1  nathanw struct rpc_createerr rpc_createerr;
     66      1.1     fvdl 
     67  1.1.6.1  nathanw #ifdef _REENTRANT
     68  1.1.6.1  nathanw static thread_key_t rce_key;
     69  1.1.6.1  nathanw static once_t rce_once = ONCE_INITIALIZER;
     70      1.1     fvdl 
     71  1.1.6.1  nathanw static void
     72  1.1.6.1  nathanw __rpc_createerr_setup(void)
     73  1.1.6.1  nathanw {
     74      1.1     fvdl 
     75  1.1.6.1  nathanw 	thr_keycreate(&rce_key, free);
     76      1.1     fvdl }
     77  1.1.6.1  nathanw #endif /* _REENTRANT */
     78      1.1     fvdl 
     79  1.1.6.1  nathanw struct rpc_createerr*
     80      1.1     fvdl __rpc_createerr()
     81      1.1     fvdl {
     82  1.1.6.1  nathanw #ifdef _REENTRANT
     83      1.1     fvdl 	struct rpc_createerr *rce_addr = 0;
     84  1.1.6.1  nathanw 	extern int __isthreaded;
     85      1.1     fvdl 
     86  1.1.6.1  nathanw 	if (__isthreaded == 0)
     87      1.1     fvdl 		return (&rpc_createerr);
     88  1.1.6.1  nathanw 	thr_once(&rce_once, __rpc_createerr_setup);
     89  1.1.6.1  nathanw 	rce_addr = thr_getspecific(rce_key);
     90  1.1.6.1  nathanw 	if (rce_addr == NULL) {
     91      1.1     fvdl 		rce_addr = (struct rpc_createerr *)
     92  1.1.6.1  nathanw 		    malloc(sizeof (struct rpc_createerr));
     93  1.1.6.1  nathanw 		thr_setspecific(rce_key, (void *) rce_addr);
     94      1.1     fvdl 		memset(rce_addr, 0, sizeof (struct rpc_createerr));
     95      1.1     fvdl 	}
     96  1.1.6.1  nathanw 
     97      1.1     fvdl 	return (rce_addr);
     98      1.1     fvdl #else
     99      1.1     fvdl 	return &rpc_createerr;
    100      1.1     fvdl #endif
    101      1.1     fvdl }
    102  1.1.6.1  nathanw 
    103