about summary refs log tree commit diff
path: root/iconv/gconv_dl.c
diff options
context:
space:
mode:
Diffstat (limited to 'iconv/gconv_dl.c')
-rw-r--r--iconv/gconv_dl.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/iconv/gconv_dl.c b/iconv/gconv_dl.c
index 308db52c83..114619ec11 100644
--- a/iconv/gconv_dl.c
+++ b/iconv/gconv_dl.c
@@ -110,6 +110,7 @@ __gconv_find_shlib (const char *name)
     {
       if (found->counter < -TRIES_BEFORE_UNLOAD)
 	{
+	  assert (found->handle == NULL);
 	  found->handle = __libc_dlopen (found->name);
 	  if (found->handle != NULL)
 	    {
@@ -162,16 +163,12 @@ do_release_shlib (const void *nodep, VISIT value, int level)
       assert (obj->counter > 0);
       --obj->counter;
     }
-  else if (obj->counter <= 0)
+  else if (obj->counter <= 0 && obj->counter >= -TRIES_BEFORE_UNLOAD
+	   && --obj->counter < -TRIES_BEFORE_UNLOAD && obj->handle != NULL)
     {
-      if (obj->counter >= -TRIES_BEFORE_UNLOAD)
-	--obj->counter;
-      if (obj->counter < -TRIES_BEFORE_UNLOAD && obj->handle != NULL)
-	{
-	  /* Unload the shared object.  */
-	  __libc_dlclose (obj->handle);
-	  obj->handle = NULL;
-	}
+      /* Unload the shared object.  */
+      __libc_dlclose (obj->handle);
+      obj->handle = NULL;
     }
 }