]> git.pld-linux.org Git - packages/proftpd.git/blame - proftpd-sendfile64.patch
- cosmetics (I've forgotten to write it before ci)
[packages/proftpd.git] / proftpd-sendfile64.patch
CommitLineData
7168921b
JR
1diff -urN proftpd-1.2.10/include/data.h proftpd-1.2.10-sendfile64/include/data.h
2--- proftpd-1.2.10/include/data.h 2004-05-21 19:19:02.000000000 +0200
3+++ proftpd-1.2.10-sendfile64/include/data.h 2005-02-03 17:18:39.676660624 +0100
4@@ -36,25 +36,12 @@
5 int pr_data_open(char *, char *, int, off_t);
6 void pr_data_close(int);
7 void pr_data_abort(int, int);
8-int pr_data_xfer(char *, int);
9+off_t pr_data_xfer(char *, int);
10 void pr_data_reset(void);
11 void pr_data_set_linger(long);
12
13 #ifdef HAVE_SENDFILE
14-typedef
15-
16-#if defined(HAVE_AIX_SENDFILE) || defined(HAVE_HPUX_SENDFILE) || \
17- defined(HAVE_LINUX_SENDFILE) || defined(HAVE_SOLARIS_SENDFILE)
18-ssize_t
19-#elif defined(HAVE_BSD_SENDFILE)
20-off_t
21-#else
22-#error "You have an unknown sendfile implementation."
23-#endif
24-
25-pr_sendfile_t;
26-
27-pr_sendfile_t pr_data_sendfile(int retr_fd, off_t *offset, size_t count);
28+off_t pr_data_sendfile(int retr_fd, off_t *offset, off_t count);
29 #endif /* HAVE_SENDFILE */
30
31 #endif /* PR_DATACONN_H */
32diff -urN proftpd-1.2.10/modules/mod_xfer.c proftpd-1.2.10-sendfile64/modules/mod_xfer.c
33--- proftpd-1.2.10/modules/mod_xfer.c 2004-08-25 00:24:18.000000000 +0200
34+++ proftpd-1.2.10-sendfile64/modules/mod_xfer.c 2005-02-03 17:18:26.109723112 +0100
35@@ -603,7 +603,7 @@
36 return;
37 }
38
39-static int _transmit_normal(char *buf, long bufsize) {
40+static off_t _transmit_normal(char *buf, long bufsize) {
41 long count;
42
43 if ((count = pr_fsio_read(retr_fh, buf, bufsize)) <= 0)
44@@ -614,7 +614,7 @@
45
46 #ifdef HAVE_SENDFILE
47 static int _transmit_sendfile(off_t count, off_t *offset,
48- pr_sendfile_t *retval) {
49+ off_t *retval) {
50
51 /* We don't use sendfile() if:
52 * - We're using bandwidth throttling.
53@@ -670,8 +670,8 @@
54 }
55 #endif /* HAVE_SENDFILE */
56
57-static long _transmit_data(off_t count, off_t offset, char *buf, long bufsize) {
58- long res;
59+static off_t _transmit_data(off_t count, off_t offset, char *buf, long bufsize) {
60+ off_t res;
61
62 #ifdef TCP_CORK
63 int on = 1;
64@@ -679,7 +679,7 @@
65 #endif /* TCP_CORK */
66
67 #ifdef HAVE_SENDFILE
68- pr_sendfile_t retval;
69+ off_t retval;
70 #endif /* HAVE_SENDFILE */
71
72 #ifdef TCP_CORK
73@@ -695,7 +695,7 @@
74 if (!_transmit_sendfile(count, &offset, &retval))
75 res = _transmit_normal(buf, bufsize);
76 else
77- res = (long) retval;
78+ res = retval;
79 #else
80 res = _transmit_normal(buf, bufsize);
81 #endif /* HAVE_SENDFILE */
82@@ -1526,8 +1526,8 @@
83 off_t nbytes_max_retrieve = 0;
84 unsigned char have_limit = FALSE;
85 privdata_t *p;
86- long bufsize, len = 0;
87- off_t respos = 0, nbytes_sent = 0, cnt_steps = 0, cnt_next = 0;
88+ long bufsize;
89+ off_t respos = 0, nbytes_sent = 0, cnt_steps = 0, cnt_next = 0, len = 0;
90
91 /* This function sets static module variables for later potential
92 * throttling of the transfer.
93diff -urN proftpd-1.2.10/src/data.c proftpd-1.2.10-sendfile64/src/data.c
94--- proftpd-1.2.10/src/data.c 2004-08-25 20:08:46.000000000 +0200
95+++ proftpd-1.2.10-sendfile64/src/data.c 2005-02-03 17:20:56.858805768 +0100
96@@ -772,9 +772,9 @@
97 * closes, or -1 if error
98 */
99
100-int pr_data_xfer(char *cl_buf, int cl_size) {
101- int len = 0;
102- int total = 0;
103+off_t pr_data_xfer(char *cl_buf, int cl_size) {
104+ off_t len = 0;
105+ off_t total = 0;
106
107 if (session.xfer.direction == PR_NETIO_IO_RD) {
108 char *buf = session.xfer.buf;
109@@ -910,9 +910,9 @@
110 * ASCII translation is not performed.
111 * return 0 if reading and data connection closes, or -1 if error
112 */
113-pr_sendfile_t pr_data_sendfile(int retr_fd, off_t *offset, size_t count) {
114+off_t pr_data_sendfile(int retr_fd, off_t *offset, off_t count) {
115 int flags, error;
116- pr_sendfile_t len = 0, total = 0;
117+ off_t len = 0, total = 0;
118 #if defined(HAVE_AIX_SENDFILE)
119 struct sf_parms parms;
120 int rc;
121@@ -932,14 +932,19 @@
122 for (;;) {
123 #if defined(HAVE_LINUX_SENDFILE) || defined(HAVE_SOLARIS_SENDFILE)
124 off_t orig_offset = *offset;
125+ off_t translen = 0;
126
127+ if (count > 1024*1024*1024)
128+ translen = 1024*1024*1024;
129+ else
130+ translen = count;
131 /* Linux semantics are fairly straightforward in a glibc 2.x world:
132 *
133 * #include <sys/sendfile.h>
134 *
135 * ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
136 */
137- len = sendfile(PR_NETIO_FD(session.d->outstrm), retr_fd, offset, count);
138+ len = sendfile(PR_NETIO_FD(session.d->outstrm), retr_fd, offset, (size_t)translen);
139
140 if (len != -1 && len < count) {
141 /* under linux semantics, this occurs when a signal has interrupted
This page took 0.087244 seconds and 4 git commands to generate.