diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-05-30 17:32:08 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-05-30 17:32:08 +0000 |
commit | 902c429174f9660eaeb255695f8f335afbfdc54a (patch) | |
tree | 2cd188cbcdfd3b82be6aa3187b7755c12b607654 /nscd/nscd.c | |
parent | ecc685684824cdbb971438ed944794d4bff4547d (diff) | |
download | glibc-902c429174f9660eaeb255695f8f335afbfdc54a.tar.gz |
* nscd/nscd.h (prune_cache): Add fd argument to prototype.cvs/fedora-glibc-20060531T1322
* 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.
Diffstat (limited to 'nscd/nscd.c')
-rw-r--r-- | nscd/nscd.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/nscd/nscd.c b/nscd/nscd.c index 16f55cfdeb..6d1e50a837 100644 --- a/nscd/nscd.c +++ b/nscd/nscd.c @@ -332,9 +332,6 @@ parse_opt (int key, char *arg, struct argp_state *state) exit (EXIT_FAILURE); request_header req; - ssize_t nbytes; - struct iovec iov[2]; - if (strcmp (arg, "passwd") == 0) req.key_len = sizeof "passwd"; else if (strcmp (arg, "group") == 0) @@ -347,17 +344,38 @@ parse_opt (int key, char *arg, struct argp_state *state) req.version = NSCD_VERSION; req.type = INVALIDATE; + struct iovec iov[2]; iov[0].iov_base = &req; iov[0].iov_len = sizeof (req); iov[1].iov_base = arg; iov[1].iov_len = req.key_len; - nbytes = TEMP_FAILURE_RETRY (writev (sock, iov, 2)); + ssize_t nbytes = TEMP_FAILURE_RETRY (writev (sock, iov, 2)); + + if (nbytes != iov[0].iov_len + iov[1].iov_len) + { + int err = errno; + close (sock); + error (EXIT_FAILURE, err, _("write incomplete")); + } + + /* Wait for ack. Older nscd just closed the socket when + prune_cache finished, silently ignore that. */ + int32_t resp = 0; + nbytes = TEMP_FAILURE_RETRY (read (sock, &resp, sizeof (resp))); + if (nbytes != 0 && nbytes != sizeof (resp)) + { + int err = errno; + close (sock); + error (EXIT_FAILURE, err, _("cannot read invalidate ACK")); + } close (sock); - exit (nbytes != iov[0].iov_len + iov[1].iov_len - ? EXIT_FAILURE : EXIT_SUCCESS); + if (resp != 0) + error (EXIT_FAILURE, resp, _("invalidation failed")); + + exit (0); } case 't': |