diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2007-03-18 18:01:40 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2007-03-18 18:01:40 +0000 |
commit | 57fa34b52e7c26f780c6bcae7a8ea863dfe710e1 (patch) | |
tree | 1fe2959ca795d67fb10559d0f300b06c2fd0b68c /libc/nscd/nscd.c | |
parent | e97d73d87846a62aff09c388bd938c0b1d410931 (diff) |
Merge changes between r1382 and r1748 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@1749 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/nscd/nscd.c')
-rw-r--r-- | libc/nscd/nscd.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/libc/nscd/nscd.c b/libc/nscd/nscd.c index d0c34eb01..ec7fceb3f 100644 --- a/libc/nscd/nscd.c +++ b/libc/nscd/nscd.c @@ -301,18 +301,18 @@ parse_opt (int key, char *arg, struct argp_state *state) error (4, 0, _("Only root is allowed to use this option!")); { int sock = nscd_open_socket (); - request_header req; - ssize_t nbytes; if (sock == -1) exit (EXIT_FAILURE); + request_header req; req.version = NSCD_VERSION; req.type = SHUTDOWN; req.key_len = 0; - nbytes = TEMP_FAILURE_RETRY (send (sock, &req, - sizeof (request_header), - MSG_NOSIGNAL)); + + ssize_t nbytes = TEMP_FAILURE_RETRY (send (sock, &req, + sizeof (request_header), + MSG_NOSIGNAL)); close (sock); exit (nbytes != sizeof (request_header) ? EXIT_FAILURE : EXIT_SUCCESS); } @@ -331,7 +331,6 @@ parse_opt (int key, char *arg, struct argp_state *state) if (sock == -1) exit (EXIT_FAILURE); - request_header req; dbtype cnt; for (cnt = pwddb; cnt < lastdb; ++cnt) if (strcmp (arg, dbnames[cnt]) == 0) @@ -340,19 +339,24 @@ parse_opt (int key, char *arg, struct argp_state *state) if (cnt == lastdb) return ARGP_ERR_UNKNOWN; - req.key_len = strlen (arg) + 1; - req.version = NSCD_VERSION; - req.type = INVALIDATE; + size_t arg_len = strlen (arg) + 1; + struct + { + request_header req; + char arg[arg_len]; + } reqdata; - 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; + reqdata.req.key_len = strlen (arg) + 1; + reqdata.req.version = NSCD_VERSION; + reqdata.req.type = INVALIDATE; + memcpy (reqdata.arg, arg, arg_len); - ssize_t nbytes = TEMP_FAILURE_RETRY (writev (sock, iov, 2)); + ssize_t nbytes = TEMP_FAILURE_RETRY (send (sock, &reqdata, + sizeof (request_header) + + arg_len, + MSG_NOSIGNAL)); - if (nbytes != iov[0].iov_len + iov[1].iov_len) + if (nbytes != sizeof (request_header) + arg_len) { int err = errno; close (sock); |