* nscd/nscd.c (parse_opt): One more conversion to use send instead

of writev.
This commit is contained in:
Ulrich Drepper 2007-02-16 19:15:07 +00:00
parent b3715c05d7
commit 8c6d104340
2 changed files with 25 additions and 16 deletions

View File

@ -1,3 +1,8 @@
2007-02-16 Ulrich Drepper <drepper@redhat.com>
* nscd/nscd.c (parse_opt): One more conversion to use send instead
of writev.
2007-02-15 Ulrich Drepper <drepper@redhat.com> 2007-02-15 Ulrich Drepper <drepper@redhat.com>
[BZ #3991] [BZ #3991]

View File

@ -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!")); error (4, 0, _("Only root is allowed to use this option!"));
{ {
int sock = nscd_open_socket (); int sock = nscd_open_socket ();
request_header req;
ssize_t nbytes;
if (sock == -1) if (sock == -1)
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
request_header req;
req.version = NSCD_VERSION; req.version = NSCD_VERSION;
req.type = SHUTDOWN; req.type = SHUTDOWN;
req.key_len = 0; req.key_len = 0;
nbytes = TEMP_FAILURE_RETRY (send (sock, &req,
sizeof (request_header), ssize_t nbytes = TEMP_FAILURE_RETRY (send (sock, &req,
MSG_NOSIGNAL)); sizeof (request_header),
MSG_NOSIGNAL));
close (sock); close (sock);
exit (nbytes != sizeof (request_header) ? EXIT_FAILURE : EXIT_SUCCESS); 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) if (sock == -1)
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
request_header req;
dbtype cnt; dbtype cnt;
for (cnt = pwddb; cnt < lastdb; ++cnt) for (cnt = pwddb; cnt < lastdb; ++cnt)
if (strcmp (arg, dbnames[cnt]) == 0) if (strcmp (arg, dbnames[cnt]) == 0)
@ -340,19 +339,24 @@ parse_opt (int key, char *arg, struct argp_state *state)
if (cnt == lastdb) if (cnt == lastdb)
return ARGP_ERR_UNKNOWN; return ARGP_ERR_UNKNOWN;
req.key_len = strlen (arg) + 1; size_t arg_len = strlen (arg) + 1;
req.version = NSCD_VERSION; struct
req.type = INVALIDATE; {
request_header req;
char arg[arg_len];
} reqdata;
struct iovec iov[2]; reqdata.req.key_len = strlen (arg) + 1;
iov[0].iov_base = &req; reqdata.req.version = NSCD_VERSION;
iov[0].iov_len = sizeof (req); reqdata.req.type = INVALIDATE;
iov[1].iov_base = arg; memcpy (reqdata.arg, arg, arg_len);
iov[1].iov_len = req.key_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; int err = errno;
close (sock); close (sock);