summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2010-09-01 04:12:55 -0700
committerUlrich Drepper <drepper@redhat.com>2010-09-01 04:12:55 -0700
commit2f3e3dc75f36367b71873eb6dda62effa5f9cd6d (patch)
treef06e6c8db8f368b981b2e4cf2662e07f55337d74
parentf3dcc2f9a52e46ecf1e7df18863e1ffea62ba37d (diff)
downloadglibc-2f3e3dc75f36367b71873eb6dda62effa5f9cd6d.tar.gz
glibc-2f3e3dc75f36367b71873eb6dda62effa5f9cd6d.tar.xz
glibc-2f3e3dc75f36367b71873eb6dda62effa5f9cd6d.zip
Remove duplicate version of pmap_getport from NIS code.
-rw-r--r--ChangeLog9
-rw-r--r--include/rpc/pmap_clnt.h5
-rw-r--r--nis/nis_findserv.c45
-rw-r--r--sunrpc/Versions2
-rw-r--r--sunrpc/pm_getport.c32
5 files changed, 43 insertions, 50 deletions
diff --git a/ChangeLog b/ChangeLog
index 834be75bfd..4fdec2cbb1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-09-01  Ulrich Drepper  <drepper@redhat.com>
+
+	* sunrpc/pm_getport.c (__libc_rpc_getport): New function.  This is
+	mainly the body of pmap_getport.  Add parameters to specify timeouts.
+	(pmap_getport): Use __libc_rpc_getport.
+	* sunrpc/Versions: Export __libc_rpc_getport with GLIBC_PRIVATE.
+	* include/rpc/pmap_clnt.h: Declare __libc_rpc_getport.
+	* nis/nis_findserv.c: Remove pmap_getport copy. Use __libc_rpc_getport.
+
 2010-08-31  Andreas Schwab  <schwab@linux-m68k.org>
 
 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list: Add
diff --git a/include/rpc/pmap_clnt.h b/include/rpc/pmap_clnt.h
index 9a22082287..b9a7063bbe 100644
--- a/include/rpc/pmap_clnt.h
+++ b/include/rpc/pmap_clnt.h
@@ -8,5 +8,10 @@ libc_hidden_proto (pmap_unset)
 /* Defined in pm_getport.c.  */
 extern int __get_socket (struct sockaddr_in *saddr)
      attribute_hidden internal_function;
+extern u_short __libc_rpc_getport (struct sockaddr_in *address, u_long program,
+				   u_long version, u_int protocol,
+				   time_t timeout_sec, time_t tottimeout_sec)
+     internal_function;
+libc_hidden_proto (__libc_rpc_getport)
 
 #endif
diff --git a/nis/nis_findserv.c b/nis/nis_findserv.c
index 472a2bf529..b1a9aa7e01 100644
--- a/nis/nis_findserv.c
+++ b/nis/nis_findserv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 2000, 2001, 2010 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -47,15 +47,6 @@ struct cu_data
   };
 
 
-/* The following is the original routine from sunrpc/pm_getport.c.
-   The only change is the much shorter timeout. */
-/*
- * pmap_getport.c
- * Client interface to pmap rpc service.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- */
-
 /*
  * Find the mapped port for program,version.
  * Calls the pmap service remotely to do the lookup.
@@ -65,39 +56,7 @@ u_short
 __pmap_getnisport (struct sockaddr_in *address, u_long program,
 		   u_long version, u_int protocol)
 {
-  const struct timeval timeout = {1, 0};
-  const struct timeval tottimeout = {1, 0};
-  u_short port = 0;
-  int socket = -1;
-  CLIENT *client;
-  struct pmap parms;
-
-  address->sin_port = htons (PMAPPORT);
-  client = clntudp_bufcreate (address, PMAPPROG, PMAPVERS, timeout, &socket,
-			      RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
-  if (client != (CLIENT *) NULL)
-    {
-      parms.pm_prog = program;
-      parms.pm_vers = version;
-      parms.pm_prot = protocol;
-      parms.pm_port = 0;	/* not needed or used */
-      if (CLNT_CALL (client, PMAPPROC_GETPORT, (xdrproc_t) xdr_pmap,
-		     (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);
-	}
-      else
-	{
-	  if (port == 0)
-	    rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
-	}
-      CLNT_DESTROY (client);
-    }
-  /* (void)close(socket); CLNT_DESTROY already closed it */
-  address->sin_port = 0;
-  return port;
+  return __libc_rpc_getport (address, program, version, protocol, 1, 1);
 }
 
 /* This is now the public function, which should find the fastest server */
diff --git a/sunrpc/Versions b/sunrpc/Versions
index d2d8e81ac0..a11dd8d36c 100644
--- a/sunrpc/Versions
+++ b/sunrpc/Versions
@@ -117,6 +117,6 @@ libc {
     xdr_quad_t; xdr_u_quad_t;
   }
   GLIBC_PRIVATE {
-    __libc_clntudp_bufcreate;
+    __libc_clntudp_bufcreate; __libc_rpc_getport;
   }
 }
diff --git a/sunrpc/pm_getport.c b/sunrpc/pm_getport.c
index 66340c0a52..da3477603e 100644
--- a/sunrpc/pm_getport.c
+++ b/sunrpc/pm_getport.c
@@ -39,11 +39,6 @@
 #include <rpc/pmap_clnt.h>
 #include <sys/socket.h>
 
-static const struct timeval timeout =
-{5, 0};
-static const struct timeval tottimeout =
-{60, 0};
-
 /*
  * Create a socket that is locally bound to a non-reserve port. For
  * any failures, -1 is returned which will cause the RPC code to
@@ -81,16 +76,24 @@ __get_socket (struct sockaddr_in *saddr)
 
 /*
  * Find the mapped port for program,version.
+ * Internal version with additional parameters.
  * Calls the pmap service remotely to do the lookup.
  * Returns 0 if no map exists.
  */
 u_short
-pmap_getport (address, program, version, protocol)
+internal_function
+__libc_rpc_getport (address, program, version, protocol, timeout_sec,
+		    tottimeout_sec)
      struct sockaddr_in *address;
      u_long program;
      u_long version;
      u_int protocol;
+     time_t timeout_sec;
+     time_t tottimeout_sec;
 {
+  const struct timeval timeout = {timeout_sec, 0};
+  const struct timeval tottimeout = {tottimeout_sec, 0};
+
   u_short port = 0;
   int socket = -1;
   CLIENT *client;
@@ -137,4 +140,21 @@ pmap_getport (address, program, version, protocol)
   address->sin_port = 0;
   return port;
 }
+libc_hidden_def (__libc_rpc_getport)
+
+
+/*
+ * Find the mapped port for program,version.
+ * Calls the pmap service remotely to do the lookup.
+ * Returns 0 if no map exists.
+ */
+u_short
+pmap_getport (address, program, version, protocol)
+     struct sockaddr_in *address;
+     u_long program;
+     u_long version;
+     u_int protocol;
+{
+  return __libc_rpc_getport (address, program, version, protocol, 5, 60);
+}
 libc_hidden_def (pmap_getport)