2001-03-20 18:35:13 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <bits/libc-lock.h>
|
|
|
|
#include <rpc/rpc.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <bits/libc-lock.h>
|
|
|
|
#include <bits/libc-tsd.h>
|
|
|
|
|
|
|
|
#ifdef _RPC_THREAD_SAFE_
|
|
|
|
|
|
|
|
|
2001-05-17 02:00:04 +00:00
|
|
|
/* Variable used in non-threaded applications or for the first thread. */
|
2001-03-20 18:35:13 +00:00
|
|
|
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();
|
|
|
|
|
2001-05-17 02:00:04 +00:00
|
|
|
if (tvp != NULL && tvp != &__libc_tsd_RPC_VARS_mem) {
|
2001-03-20 18:35:13 +00:00
|
|
|
__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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Update.
Add changes which were in this form in the original patch by
Eric Norum <eric.norum@usask.ca>.
* include/rpc/rpc.h: Remove svc_fdset, rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc/rpc.h: Declare __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
Define svc_fdset, get_rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc_thread.c: Handle first thread special, it uses the
global variables.
Define __rpc_thread_svc_fdset, __rpc_thread_createerr,
__rpc_thread_svc_pollfd, and __rpc_thread_svc_max_pollfd.
* sunrpc/Versions [libc] (GLIBC_2.2.3): Export __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
* sunrpc/clnt_gen.c: Replace use of rpc_createerr by call to
get_rpc_createerr.
* sunrpc/clnt_perr.c: Likewise.
* sunrpc/clnt_simp.c: Likewise.
* sunrpc/clnt_tcp.c: Likewise.
* sunrpc/clnt_udp.c: Likewise.
* sunrpc/clnt_unix.c: Likewise.
* sunrpc/pm_getport.c: Likewise.
2001-03-26 05:17:47 +00:00
|
|
|
/*
|
|
|
|
* Initialize RPC multi-threaded operation
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
rpc_thread_multi (void)
|
|
|
|
{
|
2001-05-17 02:00:04 +00:00
|
|
|
__libc_tsd_set (RPC_VARS, &__libc_tsd_RPC_VARS_mem);
|
Update.
Add changes which were in this form in the original patch by
Eric Norum <eric.norum@usask.ca>.
* include/rpc/rpc.h: Remove svc_fdset, rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc/rpc.h: Declare __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
Define svc_fdset, get_rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc_thread.c: Handle first thread special, it uses the
global variables.
Define __rpc_thread_svc_fdset, __rpc_thread_createerr,
__rpc_thread_svc_pollfd, and __rpc_thread_svc_max_pollfd.
* sunrpc/Versions [libc] (GLIBC_2.2.3): Export __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
* sunrpc/clnt_gen.c: Replace use of rpc_createerr by call to
get_rpc_createerr.
* sunrpc/clnt_perr.c: Likewise.
* sunrpc/clnt_simp.c: Likewise.
* sunrpc/clnt_tcp.c: Likewise.
* sunrpc/clnt_udp.c: Likewise.
* sunrpc/clnt_unix.c: Likewise.
* sunrpc/pm_getport.c: Likewise.
2001-03-26 05:17:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-20 18:35:13 +00:00
|
|
|
struct rpc_thread_variables *
|
|
|
|
__rpc_thread_variables (void)
|
|
|
|
{
|
Update.
Add changes which were in this form in the original patch by
Eric Norum <eric.norum@usask.ca>.
* include/rpc/rpc.h: Remove svc_fdset, rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc/rpc.h: Declare __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
Define svc_fdset, get_rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc_thread.c: Handle first thread special, it uses the
global variables.
Define __rpc_thread_svc_fdset, __rpc_thread_createerr,
__rpc_thread_svc_pollfd, and __rpc_thread_svc_max_pollfd.
* sunrpc/Versions [libc] (GLIBC_2.2.3): Export __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
* sunrpc/clnt_gen.c: Replace use of rpc_createerr by call to
get_rpc_createerr.
* sunrpc/clnt_perr.c: Likewise.
* sunrpc/clnt_simp.c: Likewise.
* sunrpc/clnt_tcp.c: Likewise.
* sunrpc/clnt_udp.c: Likewise.
* sunrpc/clnt_unix.c: Likewise.
* sunrpc/pm_getport.c: Likewise.
2001-03-26 05:17:47 +00:00
|
|
|
__libc_once_define (static, once);
|
2001-03-20 18:35:13 +00:00
|
|
|
struct rpc_thread_variables *tvp;
|
|
|
|
|
|
|
|
tvp = __libc_tsd_get (RPC_VARS);
|
|
|
|
if (tvp == NULL) {
|
Update.
Add changes which were in this form in the original patch by
Eric Norum <eric.norum@usask.ca>.
* include/rpc/rpc.h: Remove svc_fdset, rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc/rpc.h: Declare __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
Define svc_fdset, get_rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc_thread.c: Handle first thread special, it uses the
global variables.
Define __rpc_thread_svc_fdset, __rpc_thread_createerr,
__rpc_thread_svc_pollfd, and __rpc_thread_svc_max_pollfd.
* sunrpc/Versions [libc] (GLIBC_2.2.3): Export __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
* sunrpc/clnt_gen.c: Replace use of rpc_createerr by call to
get_rpc_createerr.
* sunrpc/clnt_perr.c: Likewise.
* sunrpc/clnt_simp.c: Likewise.
* sunrpc/clnt_tcp.c: Likewise.
* sunrpc/clnt_udp.c: Likewise.
* sunrpc/clnt_unix.c: Likewise.
* sunrpc/pm_getport.c: Likewise.
2001-03-26 05:17:47 +00:00
|
|
|
__libc_once (once, rpc_thread_multi);
|
|
|
|
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;
|
|
|
|
}
|
2001-03-20 18:35:13 +00:00
|
|
|
}
|
|
|
|
return tvp;
|
|
|
|
}
|
Update.
Add changes which were in this form in the original patch by
Eric Norum <eric.norum@usask.ca>.
* include/rpc/rpc.h: Remove svc_fdset, rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc/rpc.h: Declare __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
Define svc_fdset, get_rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc_thread.c: Handle first thread special, it uses the
global variables.
Define __rpc_thread_svc_fdset, __rpc_thread_createerr,
__rpc_thread_svc_pollfd, and __rpc_thread_svc_max_pollfd.
* sunrpc/Versions [libc] (GLIBC_2.2.3): Export __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
* sunrpc/clnt_gen.c: Replace use of rpc_createerr by call to
get_rpc_createerr.
* sunrpc/clnt_perr.c: Likewise.
* sunrpc/clnt_simp.c: Likewise.
* sunrpc/clnt_tcp.c: Likewise.
* sunrpc/clnt_udp.c: Likewise.
* sunrpc/clnt_unix.c: Likewise.
* sunrpc/pm_getport.c: Likewise.
2001-03-26 05:17:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Global variables If we're single-threaded, or if this is the first
|
|
|
|
thread using the variable, use the existing global variable. This
|
|
|
|
provides backwards compatability for existing applications which
|
|
|
|
dynamically link against this code. */
|
|
|
|
#undef svc_fdset
|
|
|
|
#undef rpc_createerr
|
|
|
|
#undef svc_pollfd
|
|
|
|
#undef svc_max_pollfd
|
|
|
|
|
|
|
|
fd_set *
|
|
|
|
__rpc_thread_svc_fdset (void)
|
|
|
|
{
|
|
|
|
struct rpc_thread_variables *tvp;
|
|
|
|
|
|
|
|
tvp = __rpc_thread_variables ();
|
2001-05-17 02:00:04 +00:00
|
|
|
if (tvp == &__libc_tsd_RPC_VARS_mem)
|
Update.
Add changes which were in this form in the original patch by
Eric Norum <eric.norum@usask.ca>.
* include/rpc/rpc.h: Remove svc_fdset, rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc/rpc.h: Declare __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
Define svc_fdset, get_rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc_thread.c: Handle first thread special, it uses the
global variables.
Define __rpc_thread_svc_fdset, __rpc_thread_createerr,
__rpc_thread_svc_pollfd, and __rpc_thread_svc_max_pollfd.
* sunrpc/Versions [libc] (GLIBC_2.2.3): Export __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
* sunrpc/clnt_gen.c: Replace use of rpc_createerr by call to
get_rpc_createerr.
* sunrpc/clnt_perr.c: Likewise.
* sunrpc/clnt_simp.c: Likewise.
* sunrpc/clnt_tcp.c: Likewise.
* sunrpc/clnt_udp.c: Likewise.
* sunrpc/clnt_unix.c: Likewise.
* sunrpc/pm_getport.c: Likewise.
2001-03-26 05:17:47 +00:00
|
|
|
return &svc_fdset;
|
|
|
|
return &tvp->svc_fdset_s;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct rpc_createerr *
|
|
|
|
__rpc_thread_createerr (void)
|
|
|
|
{
|
|
|
|
struct rpc_thread_variables *tvp;
|
|
|
|
|
|
|
|
tvp = __rpc_thread_variables ();
|
2001-05-17 02:00:04 +00:00
|
|
|
if (tvp == &__libc_tsd_RPC_VARS_mem)
|
Update.
Add changes which were in this form in the original patch by
Eric Norum <eric.norum@usask.ca>.
* include/rpc/rpc.h: Remove svc_fdset, rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc/rpc.h: Declare __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
Define svc_fdset, get_rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc_thread.c: Handle first thread special, it uses the
global variables.
Define __rpc_thread_svc_fdset, __rpc_thread_createerr,
__rpc_thread_svc_pollfd, and __rpc_thread_svc_max_pollfd.
* sunrpc/Versions [libc] (GLIBC_2.2.3): Export __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
* sunrpc/clnt_gen.c: Replace use of rpc_createerr by call to
get_rpc_createerr.
* sunrpc/clnt_perr.c: Likewise.
* sunrpc/clnt_simp.c: Likewise.
* sunrpc/clnt_tcp.c: Likewise.
* sunrpc/clnt_udp.c: Likewise.
* sunrpc/clnt_unix.c: Likewise.
* sunrpc/pm_getport.c: Likewise.
2001-03-26 05:17:47 +00:00
|
|
|
return &rpc_createerr;
|
|
|
|
return &tvp->rpc_createerr_s;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct pollfd **
|
|
|
|
__rpc_thread_svc_pollfd (void)
|
|
|
|
{
|
|
|
|
struct rpc_thread_variables *tvp;
|
|
|
|
|
|
|
|
tvp = __rpc_thread_variables ();
|
2001-05-17 02:00:04 +00:00
|
|
|
if (tvp == &__libc_tsd_RPC_VARS_mem)
|
Update.
Add changes which were in this form in the original patch by
Eric Norum <eric.norum@usask.ca>.
* include/rpc/rpc.h: Remove svc_fdset, rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc/rpc.h: Declare __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
Define svc_fdset, get_rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc_thread.c: Handle first thread special, it uses the
global variables.
Define __rpc_thread_svc_fdset, __rpc_thread_createerr,
__rpc_thread_svc_pollfd, and __rpc_thread_svc_max_pollfd.
* sunrpc/Versions [libc] (GLIBC_2.2.3): Export __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
* sunrpc/clnt_gen.c: Replace use of rpc_createerr by call to
get_rpc_createerr.
* sunrpc/clnt_perr.c: Likewise.
* sunrpc/clnt_simp.c: Likewise.
* sunrpc/clnt_tcp.c: Likewise.
* sunrpc/clnt_udp.c: Likewise.
* sunrpc/clnt_unix.c: Likewise.
* sunrpc/pm_getport.c: Likewise.
2001-03-26 05:17:47 +00:00
|
|
|
return &svc_pollfd;
|
|
|
|
return &tvp->svc_pollfd_s;
|
|
|
|
}
|
|
|
|
|
|
|
|
int *
|
|
|
|
__rpc_thread_svc_max_pollfd (void)
|
|
|
|
{
|
|
|
|
struct rpc_thread_variables *tvp;
|
|
|
|
|
|
|
|
tvp = __rpc_thread_variables ();
|
2001-05-17 02:00:04 +00:00
|
|
|
if (tvp == &__libc_tsd_RPC_VARS_mem)
|
Update.
Add changes which were in this form in the original patch by
Eric Norum <eric.norum@usask.ca>.
* include/rpc/rpc.h: Remove svc_fdset, rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc/rpc.h: Declare __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
Define svc_fdset, get_rpc_createerr, svc_pollfd, and
svc_max_pollfd.
* sunrpc/rpc_thread.c: Handle first thread special, it uses the
global variables.
Define __rpc_thread_svc_fdset, __rpc_thread_createerr,
__rpc_thread_svc_pollfd, and __rpc_thread_svc_max_pollfd.
* sunrpc/Versions [libc] (GLIBC_2.2.3): Export __rpc_thread_svc_fdset,
__rpc_thread_createerr, __rpc_thread_svc_pollfd, and
__rpc_thread_svc_max_pollfd.
* sunrpc/clnt_gen.c: Replace use of rpc_createerr by call to
get_rpc_createerr.
* sunrpc/clnt_perr.c: Likewise.
* sunrpc/clnt_simp.c: Likewise.
* sunrpc/clnt_tcp.c: Likewise.
* sunrpc/clnt_udp.c: Likewise.
* sunrpc/clnt_unix.c: Likewise.
* sunrpc/pm_getport.c: Likewise.
2001-03-26 05:17:47 +00:00
|
|
|
return &svc_max_pollfd;
|
|
|
|
return &tvp->svc_max_pollfd_s;
|
|
|
|
}
|
2001-03-20 18:35:13 +00:00
|
|
|
#endif /* _RPC_THREAD_SAFE_ */
|