4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * Define and initialize MT data for libnsl.
31 * The _libnsl_lock_init() function below is the library's .init handler.
42 extern mutex_t _ti_userlock
;
44 sigset_t fillset
; /* from sigfillset() */
46 rwlock_t svc_lock
; /* protects the services list (svc.c) */
47 rwlock_t svc_fd_lock
; /* protects svc_fdset and the xports[] array */
48 rwlock_t rpcbaddr_cache_lock
; /* protects the RPCBIND address cache */
49 static rwlock_t
*rwlock_table
[] = {
55 mutex_t authdes_lock
; /* protects authdes cache (svcauth_des.c) */
56 mutex_t authnone_lock
; /* auth_none.c serialization */
57 mutex_t authsvc_lock
; /* protects the Auths list (svc_auth.c) */
58 mutex_t clntraw_lock
; /* clnt_raw.c serialization */
59 mutex_t dname_lock
; /* domainname and domain_fd (getdname.c) */
60 /* and default_domain (rpcdname.c) */
61 mutex_t dupreq_lock
; /* dupreq variables (svc_dg.c) */
62 mutex_t keyserv_lock
; /* protects first_time and hostname */
64 mutex_t libnsl_trace_lock
; /* serializes rpc_trace() (rpc_trace.c) */
65 mutex_t loopnconf_lock
; /* loopnconf (rpcb_clnt.c) */
66 mutex_t ops_lock
; /* serializes ops initializations */
67 mutex_t portnum_lock
; /* protects ``port'' static in bindresvport() */
68 mutex_t proglst_lock
; /* protects proglst list (svc_simple.c) */
69 mutex_t rpcsoc_lock
; /* serializes clnt_com_create() (rpc_soc.c) */
70 mutex_t svcraw_lock
; /* svc_raw.c serialization */
71 mutex_t xprtlist_lock
; /* xprtlist (svc_generic.c) */
72 mutex_t serialize_pkey
; /* serializes calls to public key routines */
73 mutex_t svc_thr_mutex
; /* protects thread related variables */
74 mutex_t svc_mutex
; /* protects service handle free lists */
75 mutex_t svc_exit_mutex
; /* used for clean mt exit */
77 static mutex_t
*mutex_table
[] = {
99 cond_t svc_thr_fdwait
; /* threads wait on this for work */
104 (void) mutex_lock(&_ti_userlock
);
108 _libnsl_child_atfork()
110 (void) mutex_unlock(&_ti_userlock
);
114 _libnsl_parent_atfork()
116 (void) mutex_unlock(&_ti_userlock
);
119 #pragma init(_libnsl_lock_init)
126 (void) sigfillset(&fillset
);
128 for (i
= 0; i
< (sizeof (mutex_table
) / sizeof (mutex_table
[0])); i
++)
129 (void) mutex_init(mutex_table
[i
], 0, NULL
);
131 for (i
= 0; i
< (sizeof (rwlock_table
) / sizeof (rwlock_table
[0])); i
++)
132 (void) rwlock_init(rwlock_table
[i
], 0, NULL
);
134 (void) cond_init(&svc_thr_fdwait
, USYNC_THREAD
, 0);
137 * There is no way to unregister these atfork functions,
138 * but we don't need to. The dynamic linker and libc take
139 * care of unregistering them if/when the library is unloaded.
141 (void) pthread_atfork(_libnsl_prefork
,
142 _libnsl_parent_atfork
, _libnsl_child_atfork
);
145 #pragma fini(_libnsl_fini)
147 void _key_call_fini(void);
157 struct rpc_createerr rpc_createerr
;
159 struct rpc_createerr
*
162 static pthread_key_t rce_key
= PTHREAD_ONCE_KEY_NP
;
163 struct rpc_createerr
*rce_addr
;
166 return (&rpc_createerr
);
167 rce_addr
= thr_get_storage(&rce_key
, sizeof (*rce_addr
), free
);
168 if (rce_addr
== NULL
) {
169 syslog(LOG_ERR
, "__rpc_createerr : out of memory.");
170 return (&rpc_createerr
);
177 struct rpc_err rpc_callerr
;
182 static pthread_key_t rpc_callerr_key
= PTHREAD_ONCE_KEY_NP
;
186 return (&rpc_callerr
);
187 tsd
= thr_get_storage(&rpc_callerr_key
, sizeof (struct rpc_err
), free
);
189 syslog(LOG_ERR
, "__rpc_callerr : out of memory.");
190 return (&rpc_callerr
);