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/clnt_simp.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'sunrpc/clnt_simp.c') diff --git a/sunrpc/clnt_simp.c b/sunrpc/clnt_simp.c index 19c03b0..03b65cd 100644 --- a/sunrpc/clnt_simp.c +++ b/sunrpc/clnt_simp.c @@ -47,20 +47,24 @@ static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro"; #include #include -static struct callrpc_private +struct callrpc_private_s { CLIENT *client; int socket; u_long oldprognum, oldversnum, valid; char *oldhost; - } - *callrpc_private; + }; +#ifdef _RPC_THREAD_SAFE_ +#define callrpc_private ((struct callrpc_private_s *)RPC_THREAD_VARIABLE(callrpc_private_s)) +#else +static struct callrpc_private_s *callrpc_private; +#endif int callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum, xdrproc_t inproc, const char *in, xdrproc_t outproc, char *out) { - struct callrpc_private *crp = callrpc_private; + struct callrpc_private_s *crp = callrpc_private; struct sockaddr_in server_addr; enum clnt_stat clnt_stat; struct hostent hostbuf, *hp; @@ -68,7 +72,7 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum, if (crp == 0) { - crp = (struct callrpc_private *) calloc (1, sizeof (*crp)); + crp = (struct callrpc_private_s *) calloc (1, sizeof (*crp)); if (crp == 0) return 0; callrpc_private = crp; @@ -141,3 +145,17 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum, crp->valid = 0; return (int) clnt_stat; } + +#ifdef _RPC_THREAD_SAFE_ +void +__rpc_thread_clnt_cleanup (void) +{ + struct callrpc_private_s *rcp = RPC_THREAD_VARIABLE(callrpc_private_s); + + if (rcp) { + if (rcp->client) + CLNT_DESTROY (rcp->client); + free (rcp); + } +} +#endif /* _RPC_THREAD_SAFE_ */ -- cgit v1.1