about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-10-06 17:31:01 +0000
committerUlrich Drepper <drepper@redhat.com>2007-10-06 17:31:01 +0000
commit718946816cf60374f9d8f674d3ed649fdb33205a (patch)
treea2befe80614613e0109e3914301aac31867c3bb7
parentd10737e48042c1db723dc77bfb31478f7885b1d1 (diff)
downloadglibc-718946816cf60374f9d8f674d3ed649fdb33205a.tar.gz
glibc-718946816cf60374f9d8f674d3ed649fdb33205a.tar.xz
glibc-718946816cf60374f9d8f674d3ed649fdb33205a.zip
[BZ #5010]
2007-10-06  Ulrich Drepper  <drepper@redhat.com>
	[BZ #5010]
	* sunrpc/svc.c (struct svc_callout): Add sc_mapped element.
	(svc_register): Initialize sc_mapped.  Set to TRUE if call to
	map service succeeded.
	(svc_is_mapped): New function.
	(svc_unregister): Use it before trying to unmap service.
-rw-r--r--ChangeLog9
-rw-r--r--sunrpc/svc.c23
2 files changed, 30 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3132013271..08130dbfdd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-10-06  Ulrich Drepper  <drepper@redhat.com>
+
+	[BZ #5010]
+	* sunrpc/svc.c (struct svc_callout): Add sc_mapped element.
+	(svc_register): Initialize sc_mapped.  Set to TRUE if call to
+	map service succeeded.
+	(svc_is_mapped): New function.
+	(svc_unregister): Use it before trying to unmap service.
+
 2007-10-05  Ulrich Drepper  <drepper@redhat.com>
 
 	* timezone/zic.c: Update from tzcode2007h.
diff --git a/sunrpc/svc.c b/sunrpc/svc.c
index 1e358e247c..60f6fcdd79 100644
--- a/sunrpc/svc.c
+++ b/sunrpc/svc.c
@@ -61,6 +61,7 @@ struct svc_callout {
   rpcprog_t sc_prog;
   rpcvers_t sc_vers;
   void (*sc_dispatch) (struct svc_req *, SVCXPRT *);
+  bool_t sc_mapped;
 };
 #ifdef _RPC_THREAD_SAFE_
 #define svc_head RPC_THREAD_VARIABLE(svc_head_s)
@@ -160,6 +161,17 @@ done:
   return s;
 }
 
+
+static bool_t
+svc_is_mapped (rpcprog_t prog, rpcvers_t vers)
+{
+  struct svc_callout *prev;
+  register struct svc_callout *s;
+  s = svc_find (prog, vers, &prev);
+  return s!= NULL_SVC && s->sc_mapped;
+}
+
+
 /* Add a service program to the callout list.
    The dispatch routine will be called when a rpc request for this
    program number comes in. */
@@ -185,12 +197,18 @@ svc_register (SVCXPRT * xprt, rpcprog_t prog, rpcvers_t vers,
   s->sc_vers = vers;
   s->sc_dispatch = dispatch;
   s->sc_next = svc_head;
+  s->sc_mapped = FALSE;
   svc_head = s;
 
 pmap_it:
   /* now register the information with the local binder service */
   if (protocol)
-    return pmap_set (prog, vers, protocol, xprt->xp_port);
+    {
+      if (! pmap_set (prog, vers, protocol, xprt->xp_port))
+	return FALSE;
+
+      s->sc_mapped = TRUE;
+    }
 
   return TRUE;
 }
@@ -214,7 +232,8 @@ svc_unregister (rpcprog_t prog, rpcvers_t vers)
   s->sc_next = NULL_SVC;
   mem_free ((char *) s, (u_int) sizeof (struct svc_callout));
   /* now unregister the information with the local binder service */
-  pmap_unset (prog, vers);
+  if (! svc_is_mapped (prog, vers))
+    pmap_unset (prog, vers);
 }
 libc_hidden_def (svc_unregister)