]>
Commit | Line | Data |
---|---|---|
1 | --- apache_1.3.12/src/main/buff.c~ Sun Feb 27 07:16:27 2000 | |
2 | +++ apache_1.3.12/src/main/buff.c Sun Feb 27 07:39:15 2000 | |
3 | @@ -1133,6 +1133,102 @@ | |
4 | } | |
5 | #endif | |
6 | ||
7 | +/* The SGI Performance patch replaces writev_it_all by ap_bwritev | |
8 | + * We don't want this, as it breaks mod_ssl ... the code is commented | |
9 | + * out for now. | |
10 | + * | |
11 | + * static int writev_it_all(BUFF *fb, struct iovec *vec, int nvec) | |
12 | + * { | |
13 | + * return (ap_bwritev(fb, vec, nvec) >= 0) ? 0 : -1; | |
14 | + * } | |
15 | + * | |
16 | + */ | |
17 | + | |
18 | +/* | |
19 | + * Write data using writev() if available, write() otherwise. | |
20 | + * Returns number of bytes written or -1 on error. | |
21 | + * Note that it may modify iov; | |
22 | + */ | |
23 | +API_EXPORT(int) | |
24 | +ap_bwritev(BUFF *fb, struct iovec *iov, int iovcnt) | |
25 | +{ | |
26 | + int rval; | |
27 | + | |
28 | + if ((fb->flags & (B_EOUT | B_WRERR | B_WR)) == B_WR) { | |
29 | +#ifndef NO_WRITEV | |
30 | + int i, len; | |
31 | + | |
32 | + rval = 0; | |
33 | + | |
34 | + len = 0; | |
35 | + for (i = 0; i < iovcnt; i++) | |
36 | + len += iov[i].iov_len; | |
37 | + | |
38 | + while (len > 0) { | |
39 | + int w; | |
40 | + | |
41 | + w = (iovcnt > 1) ? (int) writev(fb->fd, iov, iovcnt) : | |
42 | + (int) write(fb->fd, iov->iov_base, iov->iov_len); | |
43 | + if (w >= 0) { | |
44 | + rval += w; | |
45 | + fb->bytes_sent += w; | |
46 | + | |
47 | + len -= w; | |
48 | + if (len == 0) | |
49 | + break; /* shortcut the common case */ | |
50 | + | |
51 | + while (w > iov[0].iov_len) { | |
52 | + w -= iov[0].iov_len; | |
53 | + iov++; | |
54 | + iovcnt--; | |
55 | + } | |
56 | + iov[0].iov_base = (char *) iov[0].iov_base + w; | |
57 | + iov[0].iov_len -= w; | |
58 | + } else if (errno != EINTR && errno != EAGAIN) { | |
59 | + doerror(fb, B_WR); | |
60 | + rval = -1; | |
61 | + break; | |
62 | + } | |
63 | + | |
64 | + if (fb->flags & B_EOUT) { /* set asynchronously */ | |
65 | + rval = -1; | |
66 | + break; | |
67 | + } | |
68 | + } | |
69 | +#else | |
70 | + int i; | |
71 | + | |
72 | + rval = 0; | |
73 | + for (i = 0; i < iovcnt; i++) { | |
74 | + while (iov[i].iov_len > 0) { | |
75 | + int w; | |
76 | + | |
77 | + w = write(fb->fd, iov[i].iov_base, iov[i].iov_len); | |
78 | + if (w >= 0) { | |
79 | + rval += w; | |
80 | + fb->bytes_sent += w; | |
81 | + iov[i].iov_base = (char *) iov[i].iov_base + w; | |
82 | + iov[i].iov_len -= w; | |
83 | + } else if (errno != EINTR && errno != EAGAIN) { | |
84 | + doerror(fb, B_WR); | |
85 | + rval = -1; | |
86 | + break; | |
87 | + } | |
88 | + | |
89 | + if (fb->flags & B_EOUT) { /* set asynchronously */ | |
90 | + rval = -1; | |
91 | + break; | |
92 | + } | |
93 | + } | |
94 | + } | |
95 | +#endif | |
96 | + } else | |
97 | + rval = -1; | |
98 | + | |
99 | + return rval; | |
100 | +} | |
101 | + | |
102 | + | |
103 | /* A wrapper for buff_write which deals with error conditions and | |
104 | * bytes_sent. Also handles non-blocking writes. | |
105 | */ |