about summary refs log tree commit diff
path: root/sunrpc/svc_simple.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-03-20 18:35:13 +0000
committerUlrich Drepper <drepper@redhat.com>2001-03-20 18:35:13 +0000
commitf1e4a4a403f740c153acfc0cd96ecc5aa542e341 (patch)
tree55d564a6eba26109ea12055a24b7846c1a100fa4 /sunrpc/svc_simple.c
parent373e6a512c30b2e34ac4a6f5b154edf45f400b35 (diff)
downloadglibc-f1e4a4a403f740c153acfc0cd96ecc5aa542e341.tar.gz
glibc-f1e4a4a403f740c153acfc0cd96ecc5aa542e341.tar.xz
glibc-f1e4a4a403f740c153acfc0cd96ecc5aa542e341.zip
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 <eric.norum@usask.ca>.
Diffstat (limited to 'sunrpc/svc_simple.c')
-rw-r--r--sunrpc/svc_simple.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/sunrpc/svc_simple.c b/sunrpc/svc_simple.c
index 949ebba627..979b5b69df 100644
--- a/sunrpc/svc_simple.c
+++ b/sunrpc/svc_simple.c
@@ -51,24 +51,33 @@ static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
 # define fputs(s, f) _IO_fputs (s, f)
 #endif
 
-static struct proglst
+struct proglst_
   {
     char *(*p_progname) (char *);
     int p_prognum;
     int p_procnum;
     xdrproc_t p_inproc, p_outproc;
-    struct proglst *p_nxt;
-  }
- *proglst;
+    struct proglst_ *p_nxt;
+  };
+#ifdef _RPC_THREAD_SAFE_
+#define proglst ((struct proglst_ *)RPC_THREAD_VARIABLE(svcsimple_proglst_s))
+#else
+static struct proglst_ *proglst;
+#endif
+
 
-static void universal (struct svc_req *rqstp, SVCXPRT *transp);
+static void universal (struct svc_req *rqstp, SVCXPRT *transp_s);
+#ifdef _RPC_THREAD_SAFE_
+#define transp ((SVCXPRT *)RPC_THREAD_VARIABLE(svcsimple_transp_s))
+#else
 static SVCXPRT *transp;
+#endif
 
 int
 registerrpc (u_long prognum, u_long versnum, u_long procnum,
 	     char *(*progname) (char *), xdrproc_t inproc, xdrproc_t outproc)
 {
-  struct proglst *pl;
+  struct proglst_ *pl;
 
   if (procnum == NULLPROC)
     {
@@ -93,7 +102,7 @@ registerrpc (u_long prognum, u_long versnum, u_long procnum,
 		      prognum, versnum);
       return -1;
     }
-  pl = (struct proglst *) malloc (sizeof (struct proglst));
+  pl = (struct proglst_ *) malloc (sizeof (struct proglst_));
   if (pl == NULL)
     {
       (void) fprintf (stderr, _("registerrpc: out of memory\n"));
@@ -110,19 +119,19 @@ registerrpc (u_long prognum, u_long versnum, u_long procnum,
 }
 
 static void
-universal (struct svc_req *rqstp, SVCXPRT *transp)
+universal (struct svc_req *rqstp, SVCXPRT *transp_l)
 {
   int prog, proc;
   char *outdata;
   char xdrbuf[UDPMSGSIZE];
-  struct proglst *pl;
+  struct proglst_ *pl;
 
   /*
    * enforce "procnum 0 is echo" convention
    */
   if (rqstp->rq_proc == NULLPROC)
     {
-      if (svc_sendreply (transp, (xdrproc_t)xdr_void, (char *) NULL) == FALSE)
+      if (svc_sendreply (transp_l, (xdrproc_t)xdr_void, (char *) NULL) == FALSE)
 	{
 	  (void) fprintf (stderr, "xxx\n");
 	  exit (1);
@@ -136,16 +145,16 @@ universal (struct svc_req *rqstp, SVCXPRT *transp)
       {
 	/* decode arguments into a CLEAN buffer */
 	__bzero (xdrbuf, sizeof (xdrbuf));	/* required ! */
-	if (!svc_getargs (transp, pl->p_inproc, xdrbuf))
+	if (!svc_getargs (transp_l, pl->p_inproc, xdrbuf))
 	  {
-	    svcerr_decode (transp);
+	    svcerr_decode (transp_l);
 	    return;
 	  }
 	outdata = (*(pl->p_progname)) (xdrbuf);
 	if (outdata == NULL && pl->p_outproc != (xdrproc_t)xdr_void)
 	  /* there was an error */
 	  return;
-	if (!svc_sendreply (transp, pl->p_outproc, outdata))
+	if (!svc_sendreply (transp_l, pl->p_outproc, outdata))
 	  {
 	    (void) fprintf (stderr,
 			    _ ("trouble replying to prog %d\n"),
@@ -153,7 +162,7 @@ universal (struct svc_req *rqstp, SVCXPRT *transp)
 	    exit (1);
 	  }
 	/* free the decoded arguments */
-	(void) svc_freeargs (transp, pl->p_inproc, xdrbuf);
+	(void) svc_freeargs (transp_l, pl->p_inproc, xdrbuf);
 	return;
       }
   (void) fprintf (stderr, _ ("never registered prog %d\n"), prog);