Skip to content

Commit

Permalink
* nscd/connections.c (sighup_pending): New variable.
Browse files Browse the repository at this point in the history
	(nscd_run): If sighup_pending, prune all 3 caches.
	(sighup_handler): Don't prune caches here, rather just set
	sighup_pending flag.
  • Loading branch information
Jakub Jelinek committed May 10, 2007
1 parent 96bad00 commit 6bad2cd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
46 changes: 34 additions & 12 deletions nscd/connections.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand All @@ -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. */
Expand Down Expand Up @@ -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;
}

0 comments on commit 6bad2cd

Please sign in to comment.