1 /* @(#)mt_misc.c 1.24 93/04/29 SMI */
2 /* $NetBSD: mt_misc.c,v 1.1 2000/06/02 23:11:11 fvdl Exp $ */
3 /* $FreeBSD: src/lib/libc/rpc/mt_misc.c,v 1.7 2006/02/27 22:10:59 deischen Exp $ */
11 #include "un-namespace.h"
14 /* Take these objects out of the application namespace. */
15 #define svc_lock __svc_lock
16 #define svc_fd_lock __svc_fd_lock
17 #define rpcbaddr_cache_lock __rpcbaddr_cache_lock
18 #define authdes_ops_lock __authdes_ops_lock
19 #define authnone_lock __authnone_lock
20 #define authsvc_lock __authsvc_lock
21 #define clnt_fd_lock __clnt_fd_lock
22 #define clntraw_lock __clntraw_lock
23 #define dupreq_lock __dupreq_lock
24 #define loopnconf_lock __loopnconf_lock
25 #define ops_lock __ops_lock
26 #define proglst_lock __proglst_lock
27 #define rpcsoc_lock __rpcsoc_lock
28 #define svcraw_lock __svcraw_lock
29 #define tsd_lock __tsd_lock
30 #define xprtlist_lock __xprtlist_lock
32 /* protects the services list (svc.c) */
33 pthread_rwlock_t svc_lock
= PTHREAD_RWLOCK_INITIALIZER
;
35 /* protects svc_fdset and the xports[] array */
36 pthread_rwlock_t svc_fd_lock
= PTHREAD_RWLOCK_INITIALIZER
;
38 /* protects the RPCBIND address cache */
39 pthread_rwlock_t rpcbaddr_cache_lock
= PTHREAD_RWLOCK_INITIALIZER
;
41 /* serializes authdes ops initializations */
42 pthread_mutex_t authdes_ops_lock
= PTHREAD_MUTEX_INITIALIZER
;
44 /* protects des stats list */
45 pthread_mutex_t svcauthdesstats_lock
= PTHREAD_MUTEX_INITIALIZER
;
47 /* auth_none.c serialization */
48 pthread_mutex_t authnone_lock
= PTHREAD_MUTEX_INITIALIZER
;
50 /* protects the Auths list (svc_auth.c) */
51 pthread_mutex_t authsvc_lock
= PTHREAD_MUTEX_INITIALIZER
;
53 /* protects client-side fd lock array */
54 pthread_mutex_t clnt_fd_lock
= PTHREAD_MUTEX_INITIALIZER
;
56 /* clnt_raw.c serialization */
57 pthread_mutex_t clntraw_lock
= PTHREAD_MUTEX_INITIALIZER
;
59 /* dupreq variables (svc_dg.c) */
60 pthread_mutex_t dupreq_lock
= PTHREAD_MUTEX_INITIALIZER
;
62 /* loopnconf (rpcb_clnt.c) */
63 pthread_mutex_t loopnconf_lock
= PTHREAD_MUTEX_INITIALIZER
;
65 /* serializes ops initializations */
66 pthread_mutex_t ops_lock
= PTHREAD_MUTEX_INITIALIZER
;
68 /* protects proglst list (svc_simple.c) */
69 pthread_mutex_t proglst_lock
= PTHREAD_MUTEX_INITIALIZER
;
71 /* serializes clnt_com_create() (rpc_soc.c) */
72 pthread_mutex_t rpcsoc_lock
= PTHREAD_MUTEX_INITIALIZER
;
74 /* svc_raw.c serialization */
75 pthread_mutex_t svcraw_lock
= PTHREAD_MUTEX_INITIALIZER
;
77 /* protects TSD key creation */
78 pthread_mutex_t tsd_lock
= PTHREAD_MUTEX_INITIALIZER
;
80 /* xprtlist (svc_generic.c) */
81 pthread_mutex_t xprtlist_lock
= PTHREAD_MUTEX_INITIALIZER
;
85 struct rpc_createerr rpc_createerr
;
87 struct rpc_createerr
*
90 static thread_key_t rce_key
= 0;
91 struct rpc_createerr
*rce_addr
= 0;
94 return (&rpc_createerr
);
96 (struct rpc_createerr
*)thr_getspecific(rce_key
)) != 0) {
97 mutex_lock(&tsd_lock
);
98 if (thr_keycreate(&rce_key
, free
) != 0) {
99 mutex_unlock(&tsd_lock
);
100 return (&rpc_createerr
);
102 mutex_unlock(&tsd_lock
);
105 rce_addr
= (struct rpc_createerr
*)
106 malloc(sizeof (struct rpc_createerr
));
107 if (thr_setspecific(rce_key
, (void *) rce_addr
) != 0) {
110 return (&rpc_createerr
);
112 memset(rce_addr
, 0, sizeof (struct rpc_createerr
));