about summary refs log tree commit diff
path: root/sunrpc/rpc_thread.c
blob: 0b004c403fa3ec74c0e50e11ba6471d304772098 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#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_


/* 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_ */