* nscd/connections.c (sighup_pending): New variable.
authorjakub <jakub>
Thu, 10 May 2007 17:07:26 +0000 (17:07 +0000)
committerjakub <jakub>
Thu, 10 May 2007 17:07:26 +0000 (17:07 +0000)
(nscd_run): If sighup_pending, prune all 3 caches.
(sighup_handler): Don't prune caches here, rather just set
sighup_pending flag.

ChangeLog
nscd/connections.c

index 079a98e..8f28cff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-07-02  Jakub Jelinek  <jakub@redhat.com>
+
+       * nscd/connections.c (sighup_pending): New variable.
+       (nscd_run): If sighup_pending, prune all 3 caches.
+       (sighup_handler): Don't prune caches here, rather just set
+       sighup_pending flag.
+
 2007-05-09  Jakub Jelinek  <jakub@redhat.com>
 
        * sysdeps/ia64/fpu/fraiseexcpt.c (feraiseexcept): Don't raise overflow
index 4e01b31..c3f9d0e 100644 (file)
@@ -68,6 +68,7 @@ static gid_t *server_groups;
 # define NGROUPS 32
 #endif
 static int server_ngroups;
+static volatile int sighup_pending;
 
 static pthread_attr_t attr;
 
@@ -1363,6 +1364,10 @@ nscd_run (void *p)
              if (readylist == NULL && to == ETIMEDOUT)
                {
                  --nready;
+
+                 if (sighup_pending)
+                   goto sighup_prune;
+
                  pthread_mutex_unlock (&readylist_lock);
                  goto only_prune;
                }
@@ -1372,6 +1377,34 @@ nscd_run (void *p)
            pthread_cond_wait (&readylist_cond, &readylist_lock);
        }
 
+      if (sighup_pending)
+       {
+         --nready;
+         pthread_cond_signal (&readylist_cond);
+       sighup_prune:
+         sighup_pending = 0;
+         pthread_mutex_unlock (&readylist_lock);
+
+         /* Prune the password database.  */
+         if (dbs[pwddb].enabled)
+           prune_cache (&dbs[pwddb], LONG_MAX, -1);
+
+         /* Prune the group database.  */
+         if (dbs[grpdb].enabled)
+           prune_cache (&dbs[grpdb], LONG_MAX, -1);
+
+         /* Prune the host database.  */
+         if (dbs[hstdb].enabled)
+           prune_cache (&dbs[hstdb], LONG_MAX, -1);
+
+         /* Re-locking.  */
+         pthread_mutex_lock (&readylist_lock);
+
+         /* One more thread available.  */
+         ++nready;
+         continue;
+       }
+
       struct fdlist *it = readylist->next;
       if (readylist->next == readylist)
        /* Just one entry on the list.  */
@@ -1952,16 +1985,5 @@ finish_drop_privileges (void)
 void
 sighup_handler (int signum)
 {
-  /* Prune the password database.  */
-  if (dbs[pwddb].enabled)
-    prune_cache (&dbs[pwddb], LONG_MAX, -1);
-    
-  /* Prune the group database.  */
-  if (dbs[grpdb].enabled)
-    prune_cache (&dbs[grpdb], LONG_MAX, -1);
-
-  /* Prune the host database.  */
-  if (dbs[hstdb].enabled)
-    prune_cache (&dbs[hstdb], LONG_MAX, -1);
+  sighup_pending = 1;
 }
-