From f1e4a4a403f740c153acfc0cd96ecc5aa542e341 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 20 Mar 2001 18:35:13 +0000 Subject: Update. * sunrpc/Makefile (routines): Add rpc_thread. (CPPFLAGS): Add -D_RPC_THREAD_SAFE. * sunrpc/rpc_thread.c: New file. * sunrpc/Versions [libc] (GLIBC_2.2.3): Export __rpc_thread_destroy. * sunrpc/auth_none.c: Don't use global variables. Access state in thread-local storage. * sunrpc/clnt_perr.c: Likewise. * sunrpc/clnt_raw.c: Likewise. * sunrpc/clnt_simp.c: Likewise. * sunrpc/key_call.c: Likewise. * sunrpc/rpc_common.c: Likewise. * sunrpc/svc.c: Likewise. * sunrpc/svc_raw.c: Likewise. * sunrpc/svc_simple.c: Likewise. * sunrpc/svcauth_des.c: Likewise. * hurd/hurd/threadvar.h (enum __hurd_threadvar_index): Add _HURD_THREADVAR_RPC_VARS. * sysdeps/generic/bits/libc-tsd.h: Mention _LIBC_TSD_KEY_RPC_VARS. * include/rpc/rpc.h: Define data structures for internal thread-local "global" variables. Based on patches by Eric Norum . --- sunrpc/rpc_thread.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 sunrpc/rpc_thread.c (limited to 'sunrpc/rpc_thread.c') diff --git a/sunrpc/rpc_thread.c b/sunrpc/rpc_thread.c new file mode 100644 index 0000000..0b004c4 --- /dev/null +++ b/sunrpc/rpc_thread.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include + +#include +#include + +#ifdef _RPC_THREAD_SAFE_ + + +/* Variable used in non-threaded applications. */ +static struct rpc_thread_variables __libc_tsd_RPC_VARS_mem; +static struct rpc_thread_variables *__libc_tsd_RPC_VARS_data = + &__libc_tsd_RPC_VARS_mem; + +/* + * Task-variable destructor + */ +void +__rpc_thread_destroy (void) +{ + struct rpc_thread_variables *tvp = __rpc_thread_variables(); + + if (tvp != NULL) { + __rpc_thread_svc_cleanup (); + __rpc_thread_clnt_cleanup (); + __rpc_thread_key_cleanup (); + free (tvp->authnone_private_s); + free (tvp->clnt_perr_buf_s); + free (tvp->clntraw_private_s); + free (tvp->svcraw_private_s); + free (tvp->authdes_cache_s); + free (tvp->authdes_lru_s); + free (tvp); + } +} + + +struct rpc_thread_variables * +__rpc_thread_variables (void) +{ + struct rpc_thread_variables *tvp; + + tvp = __libc_tsd_get (RPC_VARS); + if (tvp == NULL) { + tvp = calloc (1, sizeof *tvp); + if (tvp != NULL) + __libc_tsd_set (RPC_VARS, tvp); + else + tvp = __libc_tsd_RPC_VARS_data; + } + return tvp; +} +#endif /* _RPC_THREAD_SAFE_ */ -- cgit v1.1