Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
	* 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 <eric.norum@usask.ca>.
  • Loading branch information
Ulrich Drepper committed Mar 20, 2001
1 parent 373e6a5 commit f1e4a4a
Show file tree
Hide file tree
Showing 19 changed files with 253 additions and 67 deletions.
22 changes: 22 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
2001-03-20 Ulrich Drepper <drepper@redhat.com>

* 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 <eric.norum@usask.ca>.

* elf/dl-load.c: Various little optimizations.

* sysdeps/unix/sysv/linux/pathconf.c (__pathconf): Return
Expand Down
3 changes: 2 additions & 1 deletion bits/libc-tsd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* libc-internal interface for thread-specific data. Stub version.
Copyright (C) 1998 Free Software Foundation, Inc.
Copyright (C) 1998, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -35,6 +35,7 @@
and contains (at least):
_LIBC_TSD_KEY_MALLOC
_LIBC_TSD_KEY_DL_ERROR
_LIBC_TSD_KEY_RPC_VARS
All uses must be the literal _LIBC_TSD_* name in the __libc_tsd_* macros.
Some implementations may not provide any enum at all and instead
using string pasting in the macros. */
Expand Down
9 changes: 5 additions & 4 deletions hurd/hurd/threadvar.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Internal per-thread variables for the Hurd.
Copyright (C) 1994, 95, 97, 98, 99 Free Software Foundation, Inc.
Copyright (C) 1994, 95, 97, 98, 99, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -59,9 +59,10 @@ enum __hurd_threadvar_index
_HURD_THREADVAR_MIG_REPLY, /* Reply port for MiG user stub functions. */
_HURD_THREADVAR_ERRNO, /* `errno' value for this thread. */
_HURD_THREADVAR_SIGSTATE, /* This thread's `struct hurd_sigstate'. */
_HURD_THREADVAR_DYNAMIC_USER, /* Dynamically-assigned user variables. */
_HURD_THREADVAR_MALLOC, /* For use of malloc. */
_HURD_THREADVAR_DL_ERROR, /* For use of -ldl and dynamic linker. */
_HURD_THREADVAR_DYNAMIC_USER, /* Dynamically-assigned user variables. */
_HURD_THREADVAR_MALLOC, /* For use of malloc. */
_HURD_THREADVAR_DL_ERROR, /* For use of -ldl and dynamic linker. */
_HURD_THREADVAR_RPC_VARS, /* For state of RPC functions. */
_HURD_THREADVAR_MAX /* Default value for __hurd_threadvar_max. */
};

Expand Down
1 change: 1 addition & 0 deletions linuxthreads/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
2001-03-20 Ulrich Drepper <drepper@redhat.com>

* cancel.c (__pthread_perform_cleanup): Call __rpc_thread_destroy.
* sysdeps/pthread/bits/libc-tsd.h: Define _LIBC_TSD_KEY_VARS.

2001-03-18 Ulrich Drepper <drepper@redhat.com>

Expand Down
3 changes: 2 additions & 1 deletion linuxthreads/sysdeps/pthread/bits/libc-tsd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* libc-internal interface for thread-specific data. LinuxThreads version.
Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand All @@ -24,6 +24,7 @@
/* Fast thread-specific data internal to libc. */
enum __libc_tsd_key_t { _LIBC_TSD_KEY_MALLOC = 0,
_LIBC_TSD_KEY_DL_ERROR,
_LIBC_TSD_KEY_RPC_VARS,
_LIBC_TSD_KEY_N };

extern void *(*__libc_internal_tsd_get) (enum __libc_tsd_key_t) __THROW;
Expand Down
3 changes: 2 additions & 1 deletion sunrpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ routines := auth_none auth_unix authuxprot bindrsvprt \
clnt_gen clnt_perr clnt_raw clnt_simp clnt_tcp \
clnt_udp rpc_dtable get_myaddr getrpcport \
pmap_clnt pm_getmaps pm_getport pmap_prot \
pmap_prot2 pmap_rmt rpc_prot rpc_common rpc_cmsg \
pmap_prot2 pmap_rmt rpc_prot rpc_common rpc_cmsg rpc_thread \
svc svc_auth svc_authux svc_raw svc_run svc_simple \
svc_tcp svc_udp xdr xdr_array xdr_float xdr_mem \
xdr_rec xdr_ref xdr_stdio publickey xdr_sizeof \
Expand Down Expand Up @@ -116,6 +116,7 @@ CFLAGS-xkey_prot.c = -Wno-unused
ifeq (yes,$(have_doors))
CPPFLAGS-key_call.c += -DHAVE_DOORS=1
endif
CPPFLAGS += -D_RPC_THREAD_SAFE_

include ../Rules

Expand Down
3 changes: 3 additions & 0 deletions sunrpc/Versions
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,7 @@ libc {
GLIBC_2.2 {
svc_getreq_common; svc_getreq_poll; svc_max_pollfd; svc_pollfd;
}
GLIBC_2.2.3 {
__rpc_thread_destroy;
}
}
29 changes: 17 additions & 12 deletions sunrpc/auth_none.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
* credentials and verifiers to remote systems.
*/

#include <rpc/types.h>
#include <rpc/auth.h>
#include <rpc/rpc.h>

#define MAX_MARSHEL_SIZE 20

Expand All @@ -57,24 +56,29 @@ static struct auth_ops ops = {
authnone_destroy
};

static struct authnone_private
{
struct authnone_private_s {
AUTH no_client;
char marshalled_client[MAX_MARSHEL_SIZE];
u_int mcnt;
} *authnone_private;
};
#ifdef _RPC_THREAD_SAFE_
#define authnone_private ((struct authnone_private_ *)RPC_THREAD_VARIABLE(authnone_private_s))
#else
static struct authnone_private_s *authnone_private;
#endif

AUTH *
authnone_create (void)
{
struct authnone_private *ap = authnone_private;
struct authnone_private_s *ap;
XDR xdr_stream;
XDR *xdrs;

if (ap == 0)
ap = (struct authnone_private_s *) authnone_private;
if (ap == NULL)
{
ap = (struct authnone_private *) calloc (1, sizeof (*ap));
if (ap == 0)
ap = (struct authnone_private_s *) calloc (1, sizeof (*ap));
if (ap == NULL)
return NULL;
authnone_private = ap;
}
Expand All @@ -97,10 +101,11 @@ authnone_create (void)
static bool_t
authnone_marshal (AUTH *client, XDR *xdrs)
{
struct authnone_private *ap = authnone_private;
struct authnone_private_s *ap;

if (ap == 0)
return 0;
ap = (struct authnone_private_s *) authnone_private;
if (ap == NULL)
return FALSE;
return (*xdrs->x_ops->x_putbytes) (xdrs, ap->marshalled_client, ap->mcnt);
}

Expand Down
21 changes: 14 additions & 7 deletions sunrpc/clnt_perr.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
#include <stdio.h>
#include <string.h>
#include <libintl.h>
#include <rpc/types.h>
#include <rpc/auth.h>
#include <rpc/clnt.h>
#include <rpc/rpc.h>

#ifdef USE_IN_LIBIO
# include <libio/iolibio.h>
Expand All @@ -51,7 +49,16 @@ static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";

static char *auth_errmsg (enum auth_stat stat) internal_function;

#ifdef _RPC_THREAD_SAFE_
/*
* Making buf a preprocessor macro requires renaming the local
* buf variable in a few functions. Overriding a global variable
* with a local variable of the same name is a bad idea, anyway.
*/
#define buf ((char *)RPC_THREAD_VARIABLE(clnt_perr_buf_s))
#else
static char *buf;
#endif

static char *
_buf (void)
Expand All @@ -67,7 +74,7 @@ _buf (void)
char *
clnt_sperror (CLIENT * rpch, const char *msg)
{
char buf[1024];
char chrbuf[1024];
struct rpc_err e;
char *err;
char *str = _buf ();
Expand Down Expand Up @@ -103,7 +110,7 @@ clnt_sperror (CLIENT * rpch, const char *msg)
case RPC_CANTSEND:
case RPC_CANTRECV:
len = sprintf (str, "; errno = %s", __strerror_r (e.re_errno,
buf, sizeof buf));
chrbuf, sizeof chrbuf));
str += len;
break;

Expand Down Expand Up @@ -281,7 +288,7 @@ clnt_perrno (enum clnt_stat num)
char *
clnt_spcreateerror (const char *msg)
{
char buf[1024];
char chrbuf[1024];
char *str = _buf ();
char *cp;
int len;
Expand All @@ -301,7 +308,7 @@ clnt_spcreateerror (const char *msg)
case RPC_SYSTEMERROR:
cp = stpcpy (stpcpy (cp, " - "),
__strerror_r (rpc_createerr.cf_error.re_errno,
buf, sizeof buf));
chrbuf, sizeof chrbuf));
break;
default:
break;
Expand Down
18 changes: 11 additions & 7 deletions sunrpc/clnt_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";
/*
* This is the "network" we will be moving stuff over.
*/
static struct clntraw_private
struct clntraw_private_s
{
CLIENT client_object;
XDR xdr_stream;
char _raw_buf[UDPMSGSIZE];
char mashl_callmsg[MCALL_MSG_SIZE];
u_int mcnt;
}
*clntraw_private;
};
#ifdef _RPC_THREAD_SAFE_
#define clntraw_private ((struct clntraw_private_s *)RPC_THREAD_VARIABLE(clntraw_private_s))
#else
static struct clntraw_private_s *clntraw_private;
#endif

static enum clnt_stat clntraw_call (CLIENT *, u_long, xdrproc_t, caddr_t,
xdrproc_t, caddr_t, struct timeval);
Expand All @@ -86,14 +90,14 @@ static struct clnt_ops client_ops =
CLIENT *
clntraw_create (u_long prog, u_long vers)
{
struct clntraw_private *clp = clntraw_private;
struct clntraw_private_s *clp = clntraw_private;
struct rpc_msg call_msg;
XDR *xdrs = &clp->xdr_stream;
CLIENT *client = &clp->client_object;

if (clp == 0)
{
clp = (struct clntraw_private *) calloc (1, sizeof (*clp));
clp = (struct clntraw_private_s *) calloc (1, sizeof (*clp));
if (clp == 0)
return (0);
clntraw_private = clp;
Expand Down Expand Up @@ -136,7 +140,7 @@ clntraw_call (h, proc, xargs, argsp, xresults, resultsp, timeout)
caddr_t resultsp;
struct timeval timeout;
{
struct clntraw_private *clp = clntraw_private;
struct clntraw_private_s *clp = clntraw_private;
XDR *xdrs = &clp->xdr_stream;
struct rpc_msg msg;
enum clnt_stat status;
Expand Down Expand Up @@ -220,7 +224,7 @@ clntraw_freeres (cl, xdr_res, res_ptr)
xdrproc_t xdr_res;
caddr_t res_ptr;
{
struct clntraw_private *clp = clntraw_private;
struct clntraw_private_s *clp = clntraw_private;
XDR *xdrs = &clp->xdr_stream;
bool_t rval;

Expand Down
28 changes: 23 additions & 5 deletions sunrpc/clnt_simp.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,32 @@ static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";
#include <netdb.h>
#include <string.h>

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;
struct timeval timeout, tottimeout;

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;
Expand Down Expand Up @@ -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_ */
18 changes: 18 additions & 0 deletions sunrpc/key_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,11 @@ struct key_call_private {
pid_t pid; /* process-id at moment of creation */
uid_t uid; /* user-id at last authorization */
};
#ifdef _RPC_THREAD_SAFE_
#define key_call_private_main ((struct key_call_private *)RPC_THREAD_VARIABLE(key_call_private_s))
#else
static struct key_call_private *key_call_private_main;
#endif
__libc_lock_define_initialized (static, keycall_lock)

/*
Expand Down Expand Up @@ -610,3 +614,17 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
return key_call_keyenvoy (proc, xdr_arg, arg, xdr_rslt, rslt);
#endif
}

#ifdef _RPC_THREAD_SAFE_
void
__rpc_thread_key_cleanup (void)
{
struct key_call_private *kcp = RPC_THREAD_VARIABLE(key_call_private_s);

if (kcp) {
if (kcp->client)
clnt_destroy(kcp->client);
free (kcp);
}
}
#endif /* _RPC_THREAD_SAFE_ */
8 changes: 8 additions & 0 deletions sunrpc/rpc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
* Mountain View, California 94043
*/
#include <rpc/rpc.h>

#ifdef _RPC_THREAD_SAFE_
#undef svc_fdset
#undef rpc_createerr
#undef svc_pollfd
#undef svc_max_pollfd
#endif /* _RPC_THREAD_SAFE_ */

/*
* This file should only contain common data (global data) that is exported
* by public interfaces
Expand Down
Loading

0 comments on commit f1e4a4a

Please sign in to comment.