Version: 1
-Previous: bbf618fa3d92a034db54a1eaeabacdfb62eb692f
-Head: 3f8588b80a7117a541a88896f03e1c05860b45f4
+Previous: 3d0956a82eeedf0504a67eaeec29ac16d9fb2adf
+Head: 490b7dd0eb4396bca323b1d528a5eb0335a5384e
Applied:
real-close: 3409f8d6af187d25c63a5d1f8ee8bff5f14555e2
dup2: ca5813e7cf95dee5933fc417e4a34d26f2b01824
oobinline: ac51c1095f505373a6ec54b8f1d990259fb34d97
fork-pass: 9d661d643b62858fe119794e0ca41b5575faa0ce
fork-connect: a50a83fb4e574a2cc435bba1abf6f9df3d0cc7a6
- sendfile: 657949311ae28ad90b8a25d8d79e74b0d8751b8b
- refresh-temp: 3f8588b80a7117a541a88896f03e1c05860b45f4
+ sendfile: 490b7dd0eb4396bca323b1d528a5eb0335a5384e
Unapplied:
dbg-out: 04273ee712db4d53efb390462c1b738bb54a57df
fstat: a62c653906870422edef5f6388dac9f76c953e35
+++ /dev/null
-Bottom: 652ae6e1dadacc92be353adaafd434f1ff7ddbfa
-Top: c63a3ced205684e4a942c6b067c0553eeea44538
-Author: Sean Hefty <sean.hefty@intel.com>
-Date: 2012-08-14 12:22:51 -0700
-
-Refresh of sendfile
-
----
-
-diff --git a/src/preload.c b/src/preload.c
-index 8b86415..cbd731b 100644
---- a/src/preload.c
-+++ b/src/preload.c
-@@ -84,6 +84,7 @@ struct socket_calls {
- void *optval, socklen_t *optlen);
- int (*fcntl)(int socket, int cmd, ... /* arg */);
- int (*dup2)(int oldfd, int newfd);
-+ ssize_t (*sendfile)(int out_fd, int in_fd, off_t *offset, size_t count);
- };
-
- static struct socket_calls real;
-@@ -276,6 +277,7 @@ static void init_preload(void)
- real.getsockopt = dlsym(RTLD_NEXT, "getsockopt");
- real.fcntl = dlsym(RTLD_NEXT, "fcntl");
- real.dup2 = dlsym(RTLD_NEXT, "dup2");
-+ real.sendfile = dlsym(RTLD_NEXT, "sendfile");
-
- rs.socket = dlsym(RTLD_DEFAULT, "rsocket");
- rs.bind = dlsym(RTLD_DEFAULT, "rbind");
-@@ -1009,3 +1011,23 @@ int dup2(int oldfd, int newfd)
- atomic_inc(&oldfdi->refcnt);
- return newfd;
- }
-+
-+ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
-+{
-+ void *file_addr;
-+ int fd;
-+ size_t ret;
-+
-+ if (fd_get(out_fd, &fd) != fd_rsocket)
-+ return real.sendfile(fd, in_fd, offset, count);
-+
-+ file_addr = mmap(NULL, count, PROT_READ, 0, in_fd, offset ? *offset : 0);
-+ if (file_addr == (void *) -1)
-+ return -1;
-+
-+ len = rsend(fd, file_addr, count);
-+ if ((len > 0) && offset)
-+ lseek(in_fd, len, SEEK_CUR);
-+ munmap(file_addr, count);
-+ return ret;
-+}
Bottom: 652ae6e1dadacc92be353adaafd434f1ff7ddbfa
-Top: 652ae6e1dadacc92be353adaafd434f1ff7ddbfa
+Top: c63a3ced205684e4a942c6b067c0553eeea44538
Author: Sean Hefty <sean.hefty@intel.com>
Date: 2012-08-13 17:00:42 -0700
---
-
+diff --git a/src/preload.c b/src/preload.c
+index 8b86415..cbd731b 100644
+--- a/src/preload.c
++++ b/src/preload.c
+@@ -84,6 +84,7 @@ struct socket_calls {
+ void *optval, socklen_t *optlen);
+ int (*fcntl)(int socket, int cmd, ... /* arg */);
+ int (*dup2)(int oldfd, int newfd);
++ ssize_t (*sendfile)(int out_fd, int in_fd, off_t *offset, size_t count);
+ };
+
+ static struct socket_calls real;
+@@ -276,6 +277,7 @@ static void init_preload(void)
+ real.getsockopt = dlsym(RTLD_NEXT, "getsockopt");
+ real.fcntl = dlsym(RTLD_NEXT, "fcntl");
+ real.dup2 = dlsym(RTLD_NEXT, "dup2");
++ real.sendfile = dlsym(RTLD_NEXT, "sendfile");
+
+ rs.socket = dlsym(RTLD_DEFAULT, "rsocket");
+ rs.bind = dlsym(RTLD_DEFAULT, "rbind");
+@@ -1009,3 +1011,23 @@ int dup2(int oldfd, int newfd)
+ atomic_inc(&oldfdi->refcnt);
+ return newfd;
+ }
++
++ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
++{
++ void *file_addr;
++ int fd;
++ size_t ret;
++
++ if (fd_get(out_fd, &fd) != fd_rsocket)
++ return real.sendfile(fd, in_fd, offset, count);
++
++ file_addr = mmap(NULL, count, PROT_READ, 0, in_fd, offset ? *offset : 0);
++ if (file_addr == (void *) -1)
++ return -1;
++
++ len = rsend(fd, file_addr, count);
++ if ((len > 0) && offset)
++ lseek(in_fd, len, SEEK_CUR);
++ munmap(file_addr, count);
++ return ret;
++}