From 902c429174f9660eaeb255695f8f335afbfdc54a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 30 May 2006 17:32:08 +0000 Subject: * nscd/nscd.h (prune_cache): Add fd argument to prototype. * nscd/nscd.c (parse_opt): Read response from INVALIDATE request to make sure the database has been already invalidated. * nscd/cache.c (prune_cache): Add fd argument. Write response to fd after the cache has been invalidated. Use pthread_mutex_lock rather than pthread_mutex_trylock if fd != -1. * nscd/connections.c (invalidate_cache): Add fd argument, write response to fd if not calling prune_cache, pass fd to prune_cache. (handle_request): Adjust invalidate_cache caller. (nscd_run): Pass -1 as fd to prune_cache. --- nscd/connections.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'nscd/connections.c') diff --git a/nscd/connections.c b/nscd/connections.c index da837b5e8a..c4269ce548 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -816,9 +816,10 @@ close_sockets (void) static void -invalidate_cache (char *key) +invalidate_cache (char *key, int fd) { dbtype number; + int32_t resp; if (strcmp (key, "passwd") == 0) number = pwddb; @@ -832,10 +833,19 @@ invalidate_cache (char *key) res_init (); } else - return; + { + resp = EINVAL; + writeall (fd, &resp, sizeof (resp)); + return; + } if (dbs[number].enabled) - prune_cache (&dbs[number], LONG_MAX); + prune_cache (&dbs[number], LONG_MAX, fd); + else + { + resp = 0; + writeall (fd, &resp, sizeof (resp)); + } } @@ -1092,7 +1102,7 @@ cannot handle old request version %d; current version is %d"), else if (uid == 0) { if (req->type == INVALIDATE) - invalidate_cache (key); + invalidate_cache (key, fd); else termination_handler (0); } @@ -1438,7 +1448,7 @@ handle_request: request received (Version = %d)"), req.version); /* The pthread_cond_timedwait() call timed out. It is time to clean up the cache. */ assert (my_number < lastdb); - prune_cache (&dbs[my_number], time (NULL)); + prune_cache (&dbs[my_number], time (NULL), -1); if (clock_gettime (timeout_clock, &prune_ts) == -1) /* Should never happen. */ -- cgit v1.2.3