]> sourceware.org Git - glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Mon, 26 Mar 2001 05:17:47 +0000 (05:17 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 26 Mar 2001 05:17:47 +0000 (05:17 +0000)
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.

12 files changed:
ChangeLog
include/rpc/rpc.h
sunrpc/Versions
sunrpc/clnt_gen.c
sunrpc/clnt_perr.c
sunrpc/clnt_simp.c
sunrpc/clnt_tcp.c
sunrpc/clnt_udp.c
sunrpc/clnt_unix.c
sunrpc/pm_getport.c
sunrpc/rpc/rpc.h
sunrpc/rpc_thread.c

index bbaa5cfadecd1d109f051cd8aab9bd593b76adc1..dd499f211be61f24b0ab6655caedf0e27644af38 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,30 @@
 2001-03-25  Ulrich Drepper  <drepper@redhat.com>
 
+       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.
+
        * sysdeps/unix/sysv/linux/i386/getgroups.c (__getgroups): getgroups32
        syscall checks for negative n so don't test here as well.
 
index a922218510fc152cf21d53df199f88b26c9c89de..f4dee74afebdbb01d6a3437f6bf2de7c38fc851b 100644 (file)
@@ -48,14 +48,6 @@ extern void __rpc_thread_destroy (void);
 
 #define RPC_THREAD_VARIABLE(x) (__rpc_thread_variables()->x)
 
-/*
- * Global variables
- */
-#define svc_fdset RPC_THREAD_VARIABLE(svc_fdset_s)
-#define rpc_createerr RPC_THREAD_VARIABLE(rpc_createerr_s)
-#define svc_pollfd RPC_THREAD_VARIABLE(svc_pollfd_s)
-#define svc_max_pollfd RPC_THREAD_VARIABLE(svc_max_pollfd_s)
-
 #endif /* _RPC_THREAD_SAFE_ */
 
 #endif
index a1ab66e460a1dc8f8b1a8a5de28762894e0d85da..54b25df16f34be3870f3113862e86b4a6bdcc447 100644 (file)
@@ -110,6 +110,7 @@ libc {
     svc_getreq_common; svc_getreq_poll; svc_max_pollfd; svc_pollfd;
   }
   GLIBC_2.2.3 {
-    __rpc_thread_destroy;
+    __rpc_thread_destroy; __rpc_thread_svc_fdset; __rpc_thread_createerr;
+    __rpc_thread_svc_pollfd; __rpc_thread_svc_max_pollfd;
   }
 }
index a4fefb57e5f7677853ab8069ff6b8decd4b5801e..27e027242b5dc0501ae850aea61aaa46c72bb6c4 100644 (file)
@@ -87,7 +87,7 @@ clnt_create (const char *hostname, u_long prog, u_long vers,
         || h == NULL)
     if (herr != NETDB_INTERNAL || errno != ERANGE)
       {
-       rpc_createerr.cf_stat = RPC_UNKNOWNHOST;
+       get_rpc_createerr().cf_stat = RPC_UNKNOWNHOST;
        return NULL;
       }
     else
@@ -102,8 +102,9 @@ clnt_create (const char *hostname, u_long prog, u_long vers,
       /*
        * Only support INET for now
        */
-      rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-      rpc_createerr.cf_error.re_errno = EAFNOSUPPORT;
+      struct rpc_createerr *ce = &get_rpc_createerr ();
+      ce->cf_stat = RPC_SYSTEMERROR;
+      ce->cf_error.re_errno = EAFNOSUPPORT;
       return NULL;
     }
   sin.sin_family = h->h_addrtype;
@@ -117,8 +118,9 @@ clnt_create (const char *hostname, u_long prog, u_long vers,
         || p == NULL)
     if (errno != ERANGE)
       {
-       rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
-       rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
+       struct rpc_createerr *ce = &get_rpc_createerr ();
+       ce->cf_stat = RPC_UNKNOWNPROTO;
+       ce->cf_error.re_errno = EPFNOSUPPORT;
        return NULL;
       }
     else
@@ -163,8 +165,11 @@ clnt_create (const char *hostname, u_long prog, u_long vers,
 #endif
       break;
     default:
-      rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-      rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
+      {
+       struct rpc_createerr *ce = &get_rpc_createerr ();
+       ce->cf_stat = RPC_SYSTEMERROR;
+       ce->cf_error.re_errno = EPFNOSUPPORT;
+      }
       return (NULL);
     }
   return client;
index 24b15c04c6e8f508f9bf1edf46bbcf14323072ed..55d38153b92c183968f42de85f1b8fd473ef6c52 100644 (file)
@@ -292,22 +292,24 @@ clnt_spcreateerror (const char *msg)
   char *str = _buf ();
   char *cp;
   int len;
+  struct rpc_createerr *ce;
 
   if (str == NULL)
     return NULL;
+  ce = &get_rpc_createerr ();
   len = sprintf (str, "%s: ", msg);
   cp = str + len;
-  cp = stpcpy (cp, clnt_sperrno (rpc_createerr.cf_stat));
-  switch (rpc_createerr.cf_stat)
+  cp = stpcpy (cp, clnt_sperrno (ce->cf_stat));
+  switch (ce->cf_stat)
     {
     case RPC_PMAPFAILURE:
       cp = stpcpy (stpcpy (cp, " - "),
-                  clnt_sperrno (rpc_createerr.cf_error.re_status));
+                  clnt_sperrno (ce->cf_error.re_status));
       break;
 
     case RPC_SYSTEMERROR:
       cp = stpcpy (stpcpy (cp, " - "),
-                  __strerror_r (rpc_createerr.cf_error.re_errno,
+                  __strerror_r (ce->cf_error.re_errno,
                                 chrbuf, sizeof chrbuf));
       break;
     default:
index 03b65cdbc0da66542e9326ac34a704617430b64e..735f2edb9a5797561e2008ae6a6be2281d7ffb93 100644 (file)
@@ -127,7 +127,7 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum,
       server_addr.sin_port = 0;
       if ((crp->client = clntudp_create (&server_addr, (u_long) prognum,
                          (u_long) versnum, timeout, &crp->socket)) == NULL)
-       return (int) rpc_createerr.cf_stat;
+       return (int) get_rpc_createerr().cf_stat;
       crp->valid = 1;
       crp->oldprognum = prognum;
       crp->oldversnum = versnum;
index ad53d576d6f854d94ff042fff953db1a3d69cbfa..e3076524a73aa6b8dc3f0defd10049c11072937b 100644 (file)
@@ -123,17 +123,19 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
   h = (CLIENT *) mem_alloc (sizeof (*h));
   if (h == NULL)
     {
+      struct rpc_createerr *ce = &get_rpc_createerr ();
       (void) fprintf (stderr, _("clnttcp_create: out of memory\n"));
-      rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-      rpc_createerr.cf_error.re_errno = errno;
+      ce->cf_stat = RPC_SYSTEMERROR;
+      ce->cf_error.re_errno = errno;
       goto fooy;
     }
   /*  ct = (struct ct_data *) mem_alloc (sizeof (*ct)); */
   if (ct == NULL)
     {
+      struct rpc_createerr *ce = &get_rpc_createerr ();
       (void) fprintf (stderr, _("clnttcp_create: out of memory\n"));
-      rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-      rpc_createerr.cf_error.re_errno = errno;
+      ce->cf_stat = RPC_SYSTEMERROR;
+      ce->cf_error.re_errno = errno;
       goto fooy;
     }
 
@@ -163,8 +165,9 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
          || (__connect (*sockp, (struct sockaddr *) raddr,
                         sizeof (*raddr)) < 0))
        {
-         rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-         rpc_createerr.cf_error.re_errno = errno;
+         struct rpc_createerr *ce = &get_rpc_createerr ();
+         ce->cf_stat = RPC_SYSTEMERROR;
+         ce->cf_error.re_errno = errno;
          if (*sockp >= 0)
            (void) __close (*sockp);
          goto fooy;
index f95192305287be26e4251fae32bbb75f9fe32a8f..bf98553b8dcc782a16e7cf970caccfa58c09b9ee 100644 (file)
@@ -128,9 +128,10 @@ clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
   cl = (CLIENT *) mem_alloc (sizeof (CLIENT));
   if (cl == NULL)
     {
+      struct rpc_createerr *ce = &get_rpc_createerr ();
       (void) fprintf (stderr, _("clntudp_create: out of memory\n"));
-      rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-      rpc_createerr.cf_error.re_errno = errno;
+      ce->cf_stat = RPC_SYSTEMERROR;
+      ce->cf_error.re_errno = errno;
       goto fooy;
     }
   sendsz = ((sendsz + 3) / 4) * 4;
@@ -138,9 +139,10 @@ clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
   cu = (struct cu_data *) mem_alloc (sizeof (*cu) + sendsz + recvsz);
   if (cu == NULL)
     {
+      struct rpc_createerr *ce = &get_rpc_createerr ();
       (void) fprintf (stderr, _("clntudp_create: out of memory\n"));
-      rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-      rpc_createerr.cf_error.re_errno = errno;
+      ce->cf_stat = RPC_SYSTEMERROR;
+      ce->cf_error.re_errno = errno;
       goto fooy;
     }
   cu->cu_outbuf = &cu->cu_inbuf[recvsz];
@@ -183,8 +185,9 @@ clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
       *sockp = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
       if (*sockp < 0)
        {
-         rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-         rpc_createerr.cf_error.re_errno = errno;
+         struct rpc_createerr *ce = &get_rpc_createerr ();
+         ce->cf_stat = RPC_SYSTEMERROR;
+         ce->cf_error.re_errno = errno;
          goto fooy;
        }
       /* attempt to bind to prov port */
index 52806226fb06bd80e0a47a62845f19e2b9a9460e..19356ad032b7553744e5439bebc92fa3551f4cfd 100644 (file)
@@ -121,17 +121,19 @@ clntunix_create (struct sockaddr_un *raddr, u_long prog, u_long vers,
   h = (CLIENT *) mem_alloc (sizeof (*h));
   if (h == NULL)
     {
+      struct rpc_createerr *ce = &get_rpc_createerr ();
       (void) fputs (_("clntunix_create: out of memory\n"), stderr);
-      rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-      rpc_createerr.cf_error.re_errno = errno;
+      ce->cf_stat = RPC_SYSTEMERROR;
+      ce->cf_error.re_errno = errno;
       goto fooy;
     }
   /*  ct = (struct ct_data *) mem_alloc (sizeof (*ct)); */
   if (ct == NULL)
     {
+      struct rpc_createerr *ce = &get_rpc_createerr ();
       (void) fputs (_("clntunix_create: out of memory\n"), stderr);
-      rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-      rpc_createerr.cf_error.re_errno = errno;
+      ce->cf_stat = RPC_SYSTEMERROR;
+      ce->cf_error.re_errno = errno;
       goto fooy;
     }
 
@@ -145,8 +147,9 @@ clntunix_create (struct sockaddr_un *raddr, u_long prog, u_long vers,
       if (*sockp < 0
          || __connect (*sockp, (struct sockaddr *) raddr, len) < 0)
        {
-         rpc_createerr.cf_stat = RPC_SYSTEMERROR;
-         rpc_createerr.cf_error.re_errno = errno;
+         struct rpc_createerr *ce = &get_rpc_createerr ();
+         ce->cf_stat = RPC_SYSTEMERROR;
+         ce->cf_error.re_errno = errno;
          if (*sockp != -1)
            __close (*sockp);
          goto fooy;
index be3cb495a6b51457174d076a0678efc8646e00a2..b86472ccdfee136ed42fab9ebcd957c1db85151f 100644 (file)
@@ -70,6 +70,7 @@ pmap_getport (address, program, version, protocol)
              PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
   if (client != (CLIENT *) NULL)
     {
+      struct rpc_createerr *ce = &get_rpc_createerr ();
       parms.pm_prog = program;
       parms.pm_vers = version;
       parms.pm_prot = protocol;
@@ -78,12 +79,12 @@ pmap_getport (address, program, version, protocol)
                     (caddr_t)&parms, (xdrproc_t)xdr_u_short,
                     (caddr_t)&port, tottimeout) != RPC_SUCCESS)
        {
-         rpc_createerr.cf_stat = RPC_PMAPFAILURE;
-         clnt_geterr (client, &rpc_createerr.cf_error);
+         ce->cf_stat = RPC_PMAPFAILURE;
+         clnt_geterr (client, &ce->cf_error);
        }
       else if (port == 0)
        {
-         rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
+         ce->cf_stat = RPC_PROGNOTREGISTERED;
        }
       CLNT_DESTROY (client);
     }
index a966d2e231264bea23f0e58a3c973e675935afda..5150abf687c42e8fbd3b11dd8c97c2f189e3a1c6 100644 (file)
 /* routines for parsing /etc/rpc */
 #include <rpc/netdb.h>         /* structures and routines to parse /etc/rpc */
 
+
+/* Global variables, protected for multi-threaded applications.  */
+extern fd_set *__rpc_thread_svc_fdset (void) __attribute__ ((__const__));
+#define svc_fdset (*__rpc_thread_svc_fdset ())
+
+extern struct rpc_createerr *__rpc_thread_createerr (void)
+     __attribute__ ((__const__));
+#define get_rpc_createerr() (*__rpc_thread_createerr ())
+/* The people who "engineered" RPC should bee punished for naming the
+   data structure and the variable the same.  We cannot always define the
+   macro 'rpc_createerr' because this would prevent people from defining
+   object of type 'struct rpc_createerr'.  So we leave it up to the user
+   to select transparent replacement also of this variable.  */
+#ifdef _RPC_MT_VARS
+# define rpc_createerr (*__rpc_thread_createerr ())
+#endif
+
+extern struct pollfd **__rpc_thread_svc_pollfd (void)
+     __attribute__ ((__const__));
+#define svc_pollfd (*__rpc_thread_svc_pollfd ())
+
+extern int *__rpc_thread_svc_max_pollfd (void) __attribute__ ((__const__));
+#define svc_max_pollfd (*__rpc_thread_svc_max_pollfd ())
+
 #endif /* rpc/rpc.h */
index 0b004c403fa3ec74c0e50e11ba6471d304772098..1fd1c143ea2f0e09e30cffe0bc9cd2baf7e0a3e7 100644 (file)
@@ -14,6 +14,10 @@ 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;
 
+
+/* This is the variable used for the first thread.  */
+static struct rpc_thread_variables rpc_default;
+
 /*
  * Task-variable destructor
  */
@@ -22,7 +26,7 @@ __rpc_thread_destroy (void)
 {
        struct rpc_thread_variables *tvp = __rpc_thread_variables();
 
-       if (tvp != NULL) {
+       if (tvp != NULL && tvp != &rpc_default) {
                __rpc_thread_svc_cleanup ();
                __rpc_thread_clnt_cleanup ();
                __rpc_thread_key_cleanup ();
@@ -37,19 +41,88 @@ __rpc_thread_destroy (void)
 }
 
 
+/*
+ * Initialize RPC multi-threaded operation
+ */
+static void
+rpc_thread_multi (void)
+{
+  __libc_tsd_set (RPC_VARS, &rpc_default);
+}
+
+
 struct rpc_thread_variables *
 __rpc_thread_variables (void)
 {
+       __libc_once_define (static, once);
        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;
+               __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;
+               }
        }
        return tvp;
 }
+
+
+/* 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 ();
+       if (tvp == &rpc_default)
+               return &svc_fdset;
+       return &tvp->svc_fdset_s;
+}
+
+struct rpc_createerr *
+__rpc_thread_createerr (void)
+{
+       struct rpc_thread_variables *tvp;
+
+       tvp = __rpc_thread_variables ();
+       if (tvp == &rpc_default)
+               return &rpc_createerr;
+       return &tvp->rpc_createerr_s;
+}
+
+struct pollfd **
+__rpc_thread_svc_pollfd (void)
+{
+       struct rpc_thread_variables *tvp;
+
+       tvp = __rpc_thread_variables ();
+       if (tvp == &rpc_default)
+               return &svc_pollfd;
+       return &tvp->svc_pollfd_s;
+}
+
+int *
+__rpc_thread_svc_max_pollfd (void)
+{
+       struct rpc_thread_variables *tvp;
+
+       tvp = __rpc_thread_variables ();
+       if (tvp == &rpc_default)
+               return &svc_max_pollfd;
+       return &tvp->svc_max_pollfd_s;
+}
 #endif /* _RPC_THREAD_SAFE_ */
This page took 0.06851 seconds and 5 git commands to generate.