diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-04-02 18:24:52 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-04-02 18:24:52 +0000 |
commit | e7397b8473c8ebb49d0eabafe07cc15bf15f7944 (patch) | |
tree | 8ff8a1995bea828f163c35dba339621b12e1cd67 /nscd/nscd_helper.c | |
parent | 6c7a57538a284d495e42c9e89e6a3248b41708ce (diff) | |
download | glibc-e7397b8473c8ebb49d0eabafe07cc15bf15f7944.zip glibc-e7397b8473c8ebb49d0eabafe07cc15bf15f7944.tar.gz glibc-e7397b8473c8ebb49d0eabafe07cc15bf15f7944.tar.bz2 |
[BZ #2501]
* nscd/nscd_helper.c (get_mapping): Rewrite code to send request
so it uses send and not writev.
Diffstat (limited to 'nscd/nscd_helper.c')
-rw-r--r-- | nscd/nscd_helper.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index 8025168..fd74944 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -176,35 +176,40 @@ get_mapping (request_type type, const char *key, struct mapped_database *result = NO_MAPPING; #ifdef SCM_RIGHTS const size_t keylen = strlen (key) + 1; - char resdata[keylen]; int saved_errno = errno; int mapfd = -1; /* Send the request. */ - struct iovec iov[2]; - request_header req; + struct + { + request_header req; + char key[keylen]; + } reqdata; int sock = open_socket (); if (sock < 0) goto out; - req.version = NSCD_VERSION; - req.type = type; - req.key_len = keylen; - - iov[0].iov_base = &req; - iov[0].iov_len = sizeof (req); - iov[1].iov_base = (void *) key; - iov[1].iov_len = keylen; + reqdata.req.version = NSCD_VERSION; + reqdata.req.type = type; + reqdata.req.key_len = keylen; + memcpy (reqdata.key, key, keylen); - if (__builtin_expect (TEMP_FAILURE_RETRY (__writev (sock, iov, 2)) - != iov[0].iov_len + iov[1].iov_len, 0)) +# ifndef MSG_NOSIGNAL +# define MSG_NOSIGNAL 0 +# endif + if (__builtin_expect (TEMP_FAILURE_RETRY (__send (sock, &reqdata, + sizeof (reqdata), + MSG_NOSIGNAL)) + != sizeof (reqdata), 0)) /* We cannot even write the request. */ goto out_close2; /* Room for the data sent along with the file descriptor. We expect the key name back. */ +# define resdata reqdata.key + struct iovec iov[1]; iov[0].iov_base = resdata; iov[0].iov_len = keylen; @@ -231,11 +236,7 @@ get_mapping (request_type type, const char *key, if (wait_on_socket (sock) <= 0) goto out_close2; -# ifndef MSG_NOSIGNAL -# define MSG_NOSIGNAL 0 -# endif - if (__builtin_expect (TEMP_FAILURE_RETRY (__recvmsg (sock, &msg, - MSG_NOSIGNAL)) + if (__builtin_expect (TEMP_FAILURE_RETRY (__recvmsg (sock, &msg, 0)) != keylen, 0)) goto out_close2; |