about summary refs log tree commit diff
path: root/nscd/connections.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-02-22 22:58:32 +0000
committerUlrich Drepper <drepper@redhat.com>2005-02-22 22:58:32 +0000
commitd2dc7d84732fc832aaac4891f84d38e3748f1af7 (patch)
treed67a0482ebca5bff2bc881237fd69bf4c39901ea /nscd/connections.c
parent804bb90a5a19c5d5dc00139b9ce305cda8f3c3d4 (diff)
downloadglibc-d2dc7d84732fc832aaac4891f84d38e3748f1af7.tar.gz
glibc-d2dc7d84732fc832aaac4891f84d38e3748f1af7.tar.xz
glibc-d2dc7d84732fc832aaac4891f84d38e3748f1af7.zip
* nscd/nscd-client.h: Include sys/uio.h.
	(__readall, __readvall, writeall): New prototypes.
	* nscd/connections.c (writeall): New function.
	(handle_request): Use it.
	* nscd/aicache.c (addhstaiX): Likewise.
	* nscd/initgrcache.c (addinitgroupsX): Likewise.
	* nscd/hstcache.c (cache_addhst): Likewise.
	* nscd/grpcache.c (cache_addgr): Likewise.
	* nscd/pwdcache.c (cache_addpw): Likewise.
	* nscd/nscd_helper.c (__readall, __readvall): New functions.
	* nscd/nscd_getai.c (__nscd_getai): Use them.
	* nscd/nscd_getpw_r.c (__nscd_getpw_r): Likewise.
	* nscd/nscd_getgr_r.c (__nscd_getgr_r): Likewise.
	* nscd/nscd_gethst_r.c (__nscd_gethst_r): Likewise.
	* nscd/nscd_initgroups.c (__nscd_getgrouplist): Likewise.
Diffstat (limited to 'nscd/connections.c')
-rw-r--r--nscd/connections.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/nscd/connections.c b/nscd/connections.c
index 63a01e3bb6..86069b237a 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -181,13 +181,28 @@ static int sock;
 unsigned long int client_queued;
 
 
+ssize_t
+writeall (int fd, const void *buf, size_t len)
+{
+  size_t n = len;
+  ssize_t ret;
+  do
+    {
+      ret = TEMP_FAILURE_RETRY (write (fd, buf, n));
+      if (ret <= 0)
+	break;
+      buf = (const char *) buf + ret;
+      n -= ret;
+    }
+  while (n > 0);
+  return ret < 0 ? ret : len - n;
+}
+
+
 /* Initialize database information structures.  */
 void
 nscd_init (void)
 {
-  struct sockaddr_un sock_addr;
-  size_t cnt;
-
   /* Secure mode and unprivileged mode are incompatible */
   if (server_user != NULL && secure_in_use)
     {
@@ -204,7 +219,7 @@ nscd_init (void)
     /* No configuration for this value, assume a default.  */
     nthreads = 2 * lastdb;
 
-  for (cnt = 0; cnt < lastdb; ++cnt)
+  for (size_t cnt = 0; cnt < lastdb; ++cnt)
     if (dbs[cnt].enabled)
       {
 	pthread_rwlock_init (&dbs[cnt].lock, NULL);
@@ -500,6 +515,7 @@ cannot set socket to close on exec: %s; disabling paranoia mode"),
       exit (1);
     }
   /* Bind a name to the socket.  */
+  struct sockaddr_un sock_addr;
   sock_addr.sun_family = AF_UNIX;
   strcpy (sock_addr.sun_path, _PATH_NSCDSOCKET);
   if (bind (sock, (struct sockaddr *) &sock_addr, sizeof (sock_addr)) < 0)
@@ -691,7 +707,7 @@ cannot handle old request version %d; current version is %d"),
       if (cached != NULL)
 	{
 	  /* Hurray it's in the cache.  */
-	  if (TEMP_FAILURE_RETRY (write (fd, cached->data, cached->recsize))
+	  if (writeall (fd, cached->data, cached->recsize)
 	      != cached->recsize
 	      && __builtin_expect (debug_level, 0) > 0)
 	    {