aboutsummaryrefslogtreecommitdiff
path: root/nscd/connections.c
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 /nscd/connections.c
parent8522a053940d49e11cbb1a839b4e9ae62f9fad4a (diff)
downloadglibc-bd547139c77f2f3bb581d329e70c2c5cd246a3ab.tar
glibc-bd547139c77f2f3bb581d329e70c2c5cd246a3ab.tar.gz
glibc-bd547139c77f2f3bb581d329e70c2c5cd246a3ab.tar.bz2
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.
Diffstat (limited to 'nscd/connections.c')
-rw-r--r--nscd/connections.c25
1 files changed, 23 insertions, 2 deletions
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;