about summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2019-05-10 14:17:26 +0200
committerFlorian Weimer <fweimer@redhat.com>2019-05-10 14:52:44 +0200
commit4aee85f96b881c1cb80a1fff752b8e2130a9a4d9 (patch)
tree6e17e4b99ad67b4f25dc849064a0ce9e9d26d4b0 /nptl
parenteb669ff5bf2c8093b7e88b75e745ce3f1f4bd8a4 (diff)
downloadglibc-4aee85f96b881c1cb80a1fff752b8e2130a9a4d9.tar.gz
glibc-4aee85f96b881c1cb80a1fff752b8e2130a9a4d9.tar.xz
glibc-4aee85f96b881c1cb80a1fff752b8e2130a9a4d9.zip
sem_close: Use __twalk_r
Diffstat (limited to 'nptl')
-rw-r--r--nptl/sem_close.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/nptl/sem_close.c b/nptl/sem_close.c
index b8828cba06..8941f111f9 100644
--- a/nptl/sem_close.c
+++ b/nptl/sem_close.c
@@ -21,21 +21,20 @@
 #include <sys/mman.h>
 #include "semaphoreP.h"
 
-
-/* Global variables to parametrize the walk function.  This works
-   since we always have to use locks.  And we have to use the twalk
-   function since the entries are not sorted wrt the mapping
-   address.  */
-static sem_t *the_sem;
-static struct inuse_sem *rec;
+struct walk_closure
+{
+  sem_t *the_sem;
+  struct inuse_sem *rec;
+};
 
 static void
-walker (const void *inodep, const VISIT which, const int depth)
+walker (const void *inodep, VISIT which, void *closure0)
 {
+  struct walk_closure *closure = closure0;
   struct inuse_sem *nodep = *(struct inuse_sem **) inodep;
 
-  if (nodep->sem == the_sem)
-    rec = nodep;
+  if (nodep->sem == closure->the_sem)
+    closure->rec = nodep;
 }
 
 
@@ -48,9 +47,12 @@ sem_close (sem_t *sem)
   lll_lock (__sem_mappings_lock, LLL_PRIVATE);
 
   /* Locate the entry for the mapping the caller provided.  */
-  rec = NULL;
-  the_sem = sem;
-  __twalk (__sem_mappings, walker);
+  struct inuse_sem *rec;
+  {
+    struct walk_closure closure = { .the_sem = sem, .rec = NULL };
+    __twalk_r (__sem_mappings, walker, &closure);
+    rec = closure.rec;
+  }
   if  (rec != NULL)
     {
       /* Check the reference counter.  If it is going to be zero, free