about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-05-10 17:07:30 +0000
committerJakub Jelinek <jakub@redhat.com>2007-05-10 17:07:30 +0000
commit6bad2cd171c7d81e9a43ccc79e91009438c948ac (patch)
tree86063014188ce685e4646023929ac7751dceacf6
parent96bad006f14ac46ca7a59dc4c5ba5ed9ef7a1560 (diff)
downloadglibc-6bad2cd171c7d81e9a43ccc79e91009438c948ac.tar.gz
glibc-6bad2cd171c7d81e9a43ccc79e91009438c948ac.tar.xz
glibc-6bad2cd171c7d81e9a43ccc79e91009438c948ac.zip
* 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.
-rw-r--r--ChangeLog7
-rw-r--r--nscd/connections.c46
2 files changed, 41 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 079a98e839..8f28cffa33 100644
--- 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
diff --git a/nscd/connections.c b/nscd/connections.c
index 4e01b3182c..c3f9d0e7df 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -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;
 }
-