about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-09-03 08:15:41 +0000
committerUlrich Drepper <drepper@redhat.com>2004-09-03 08:15:41 +0000
commitead07d01fa97ad6329c9e780643a3a5631ed7589 (patch)
tree8f64d5c97830db1c4b700923a390d339dad46948
parent1da484d94afd736b9849141e6c0a28bcd15ba6c7 (diff)
downloadglibc-ead07d01fa97ad6329c9e780643a3a5631ed7589.tar.gz
glibc-ead07d01fa97ad6329c9e780643a3a5631ed7589.tar.xz
glibc-ead07d01fa97ad6329c9e780643a3a5631ed7589.zip
Update.
2004-09-03  Ulrich Drepper  <drepper@redhat.com>

	* nscd/nscd.c (parse_opt): Use writev instead of two write for
	invalidate command.
-rw-r--r--ChangeLog5
-rw-r--r--nscd/nscd.c24
2 files changed, 18 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index eaa352a60a..015d2f2618 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-09-03  Ulrich Drepper  <drepper@redhat.com>
+
+	* nscd/nscd.c (parse_opt): Use writev instead of two write for
+	invalidate command.
+
 2004-09-02  Ulrich Drepper  <drepper@redhat.com>
 
 	* nscd/connections.c (nscd_run): Check early for invalid request types.
diff --git a/nscd/nscd.c b/nscd/nscd.c
index 35e48ca348..f6b22d4179 100644
--- a/nscd/nscd.c
+++ b/nscd/nscd.c
@@ -39,6 +39,7 @@
 #include <sys/mman.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
+#include <sys/uio.h>
 #include <sys/un.h>
 
 #include "dbg_log.h"
@@ -304,12 +305,14 @@ parse_opt (int key, char *arg, struct argp_state *state)
       else
 	{
 	  int sock = nscd_open_socket ();
-	  request_header req;
-	  ssize_t nbytes;
 
 	  if (sock == -1)
 	    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)
@@ -321,19 +324,18 @@ parse_opt (int key, char *arg, struct argp_state *state)
 
 	  req.version = NSCD_VERSION;
 	  req.type = INVALIDATE;
-	  nbytes = TEMP_FAILURE_RETRY (write (sock, &req,
-					      sizeof (request_header)));
-	  if (nbytes != sizeof (request_header))
-	    {
-	      close (sock);
-	      exit (EXIT_FAILURE);
-	    }
 
-	  nbytes = TEMP_FAILURE_RETRY (write (sock, (void *)arg, req.key_len));
+	  iov[0].iov_base = &req;
+	  iov[0].iov_len = sizeof (req);
+	  iov[1].iov_base = (void *) key;
+	  iov[1].iov_len = req.key_len;
+
+	  nbytes = TEMP_FAILURE_RETRY (writev (sock, iov, 2));
 
 	  close (sock);
 
-	  exit (nbytes != req.key_len ? EXIT_FAILURE : EXIT_SUCCESS);
+	  exit (nbytes != iov[0].iov_len + iov[1].iov_len
+		? EXIT_FAILURE : EXIT_SUCCESS);
 	}
 
     case 't':