about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-11-22 19:06:27 +0000
committerUlrich Drepper <drepper@redhat.com>2005-11-22 19:06:27 +0000
commitbd547139c77f2f3bb581d329e70c2c5cd246a3ab (patch)
treef7b20ca29fca4b81fe969c7f4ebe06e2e5f7599b
parent8522a053940d49e11cbb1a839b4e9ae62f9fad4a (diff)
downloadglibc-bd547139c77f2f3bb581d329e70c2c5cd246a3ab.tar.gz
glibc-bd547139c77f2f3bb581d329e70c2c5cd246a3ab.tar.xz
glibc-bd547139c77f2f3bb581d329e70c2c5cd246a3ab.zip
* nscd/connections.c (sendfileall): Define.
	(handle_request): Use it instead of sendfile call.
	* nscd/nscd-client.h: Declare sendfileall.
	* nscd/aicache.c: Use sendfileall instead of sendfile.
	* nscd/grpcache.c: Likewise.
	* nscd/hstcache.c: Likewise.
	* nscd/initgrcache.c: Likewise.
	* nscd/pwdcache.c: Likewise.
-rw-r--r--ChangeLog9
-rw-r--r--nscd/aicache.c8
-rw-r--r--nscd/connections.c25
-rw-r--r--nscd/grpcache.c8
-rw-r--r--nscd/hstcache.c8
-rw-r--r--nscd/initgrcache.c8
-rw-r--r--nscd/nscd-client.h2
-rw-r--r--nscd/pwdcache.c8
-rw-r--r--sysdeps/generic/ldsodefs.h1
9 files changed, 49 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index b27df1736f..841a6254f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2005-11-22  Ulrich Drepper  <drepper@redhat.com>
 
+	* nscd/connections.c (sendfileall): Define.
+	(handle_request): Use it instead of sendfile call.
+	* nscd/nscd-client.h: Declare sendfileall.
+	* nscd/aicache.c: Use sendfileall instead of sendfile.
+	* nscd/grpcache.c: Likewise.
+	* nscd/hstcache.c: Likewise.
+	* nscd/initgrcache.c: Likewise.
+	* nscd/pwdcache.c: Likewise.
+
 	[BZ #1908]
 	* manual/install.texi (Tools for Compilation): Require gawk.
 
diff --git a/nscd/aicache.c b/nscd/aicache.c
index 9b8a4e50f2..59fa2df775 100644
--- a/nscd/aicache.c
+++ b/nscd/aicache.c
@@ -26,9 +26,6 @@
 #include <time.h>
 #include <unistd.h>
 #include <sys/mman.h>
-#ifdef HAVE_SENDFILE
-# include <sys/sendfile.h>
-#endif
 
 #include "dbg_log.h"
 #include "nscd.h"
@@ -382,9 +379,10 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
 			      <= (sizeof (struct database_pers_head)
 				  + db->head->module * sizeof (ref_t)
 				  + db->head->data_size));
-		      off_t off = (char *) &dataset->resp - (char *) db->head;
 		      ssize_t written;
-		      written = sendfile (fd, db->wr_fd, &off, total);
+		      written = sendfileall (fd, db->wr_fd,
+					     (char *) &dataset->resp
+					     - (char *) db->head, total);
 # ifndef __ASSUME_SENDFILE
 		      if (written == -1 && errno == ENOSYS)
 			goto use_write;
diff --git a/nscd/connections.c b/nscd/connections.c
index 0a1ca77836..a6d2a55e2f 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -204,6 +204,26 @@ writeall (int fd, const void *buf, size_t len)
 }
 
 
+#ifdef HAVE_SENDFILE
+ssize_t
+sendfileall (int tofd, int fromfd, off_t off, size_t len)
+{
+  ssize_t n = len;
+  ssize_t ret;
+
+  do
+    {
+      ret = TEMP_FAILURE_RETRY (sendfile (tofd, fromfd, &off, n));
+      if (ret <= 0)
+	break;
+      n -= ret;
+    }
+  while (n > 0);
+  return ret < 0 ? ret : len - n;
+}
+#endif
+
+
 enum usekey
   {
     use_not = 0,
@@ -957,8 +977,9 @@ cannot handle old request version %d; current version is %d"),
 		      <= (sizeof (struct database_pers_head)
 			  + db->head->module * sizeof (ref_t)
 			  + db->head->data_size));
-	      off_t off = (char *) cached->data - (char *) db->head;
-	      nwritten = sendfile (fd, db->wr_fd, &off, cached->recsize);
+	      nwritten = sendfileall (fd, db->wr_fd,
+				      (char *) cached->data
+				      - (char *) db->head, cached->recsize);
 # ifndef __ASSUME_SENDFILE
 	      if (nwritten == -1 && errno == ENOSYS)
 		goto use_write;
diff --git a/nscd/grpcache.c b/nscd/grpcache.c
index fb043152c6..81c61c7b67 100644
--- a/nscd/grpcache.c
+++ b/nscd/grpcache.c
@@ -32,9 +32,6 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/mman.h>
-#ifdef HAVE_SENDFILE
-# include <sys/sendfile.h>
-#endif
 #include <sys/socket.h>
 #include <stackinfo.h>
 
@@ -310,8 +307,9 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
 		      <= (sizeof (struct database_pers_head)
 			  + db->head->module * sizeof (ref_t)
 			  + db->head->data_size));
-	      off_t off = (char *) &dataset->resp - (char *) db->head;
-	      written = sendfile (fd, db->wr_fd, &off, total);
+	      written = sendfileall (fd, db->wr_fd,
+				     (char *) &dataset->resp
+				     - (char *) db->head, total);
 # ifndef __ASSUME_SENDFILE
 	      if (written == -1 && errno == ENOSYS)
 		goto use_write;
diff --git a/nscd/hstcache.c b/nscd/hstcache.c
index 29f14af66b..22f4d6d0a3 100644
--- a/nscd/hstcache.c
+++ b/nscd/hstcache.c
@@ -34,9 +34,6 @@
 #include <arpa/inet.h>
 #include <arpa/nameser.h>
 #include <sys/mman.h>
-#ifdef HAVE_SENDFILE
-# include <sys/sendfile.h>
-#endif
 #include <stackinfo.h>
 
 #include "nscd.h"
@@ -344,8 +341,9 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 		      <= (sizeof (struct database_pers_head)
 			  + db->head->module * sizeof (ref_t)
 			  + db->head->data_size));
-	      off_t off = (char *) &dataset->resp - (char *) db->head;
-	      written = sendfile (fd, db->wr_fd, &off, total);
+	      written = sendfileall (fd, db->wr_fd,
+				     (char *) &dataset->resp
+				     - (char *) db->head, total);
 # ifndef __ASSUME_SENDFILE
 	      if (written == -1 && errno == ENOSYS)
 		goto use_write;
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c
index eb03fc7a5d..23d5d59a11 100644
--- a/nscd/initgrcache.c
+++ b/nscd/initgrcache.c
@@ -26,9 +26,6 @@
 #include <time.h>
 #include <unistd.h>
 #include <sys/mman.h>
-#ifdef HAVE_SENDFILE
-# include <sys/sendfile.h>
-#endif
 
 #include "dbg_log.h"
 #include "nscd.h"
@@ -361,8 +358,9 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
 		      <= (sizeof (struct database_pers_head)
 			  + db->head->module * sizeof (ref_t)
 			  + db->head->data_size));
-	      off_t off = (char *) &dataset->resp - (char *) db->head;
-	      written = sendfile (fd, db->wr_fd, &off, total);
+	      written = sendfileall (fd, db->wr_fd,
+				     (char *) &dataset->resp
+				     - (char *) db->head, total);
 # ifndef __ASSUME_SENDFILE
 	      if (written == -1 && errno == ENOSYS)
 		goto use_write;
diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h
index 1389f2da19..98c167eb62 100644
--- a/nscd/nscd-client.h
+++ b/nscd/nscd-client.h
@@ -319,5 +319,7 @@ extern ssize_t __readvall (int fd, const struct iovec *iov, int iovcnt)
   attribute_hidden;
 extern ssize_t writeall (int fd, const void *buf, size_t len)
   attribute_hidden;
+extern ssize_t sendfileall (int tofd, int fromfd, off_t off, size_t len)
+  attribute_hidden;
 
 #endif /* nscd.h */
diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c
index 6f4b032d10..c3039c89c4 100644
--- a/nscd/pwdcache.c
+++ b/nscd/pwdcache.c
@@ -32,9 +32,6 @@
 #include <time.h>
 #include <unistd.h>
 #include <sys/mman.h>
-#ifdef HAVE_SENDFILE
-# include <sys/sendfile.h>
-#endif
 #include <sys/socket.h>
 #include <stackinfo.h>
 
@@ -305,8 +302,9 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
 		      <= (sizeof (struct database_pers_head)
                           + db->head->module * sizeof (ref_t)
                           + db->head->data_size));
-	      off_t off = (char *) &dataset->resp - (char *) db->head;
-	      written = sendfile (fd, db->wr_fd, &off, total);
+	      written = sendfileall (fd, db->wr_fd,
+				     (char *) &dataset->resp
+				     - (char *) db->head, total);
 # ifndef __ASSUME_SENDFILE
 	      if (written == -1 && errno == ENOSYS)
 		goto use_write;
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index b8333ed79c..67a20cea70 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -508,7 +508,6 @@ struct rtld_global
     struct dtv_slotinfo
     {
       size_t gen;
-      bool is_static;
       struct link_map *map;
     } slotinfo[0];
   } *_dl_tls_dtv_slotinfo_list;