--- apache_1.3.12/src/main/buff.c~ Sun Feb 27 07:16:27 2000 +++ apache_1.3.12/src/main/buff.c Sun Feb 27 07:39:15 2000 @@ -1133,6 +1133,102 @@ } #endif +/* The SGI Performance patch replaces writev_it_all by ap_bwritev + * We don't want this, as it breaks mod_ssl ... the code is commented + * out for now. + * + * static int writev_it_all(BUFF *fb, struct iovec *vec, int nvec) + * { + * return (ap_bwritev(fb, vec, nvec) >= 0) ? 0 : -1; + * } + * + */ + +/* + * Write data using writev() if available, write() otherwise. + * Returns number of bytes written or -1 on error. + * Note that it may modify iov; + */ +API_EXPORT(int) +ap_bwritev(BUFF *fb, struct iovec *iov, int iovcnt) +{ + int rval; + + if ((fb->flags & (B_EOUT | B_WRERR | B_WR)) == B_WR) { +#ifndef NO_WRITEV + int i, len; + + rval = 0; + + len = 0; + for (i = 0; i < iovcnt; i++) + len += iov[i].iov_len; + + while (len > 0) { + int w; + + w = (iovcnt > 1) ? (int) writev(fb->fd, iov, iovcnt) : + (int) write(fb->fd, iov->iov_base, iov->iov_len); + if (w >= 0) { + rval += w; + fb->bytes_sent += w; + + len -= w; + if (len == 0) + break; /* shortcut the common case */ + + while (w > iov[0].iov_len) { + w -= iov[0].iov_len; + iov++; + iovcnt--; + } + iov[0].iov_base = (char *) iov[0].iov_base + w; + iov[0].iov_len -= w; + } else if (errno != EINTR && errno != EAGAIN) { + doerror(fb, B_WR); + rval = -1; + break; + } + + if (fb->flags & B_EOUT) { /* set asynchronously */ + rval = -1; + break; + } + } +#else + int i; + + rval = 0; + for (i = 0; i < iovcnt; i++) { + while (iov[i].iov_len > 0) { + int w; + + w = write(fb->fd, iov[i].iov_base, iov[i].iov_len); + if (w >= 0) { + rval += w; + fb->bytes_sent += w; + iov[i].iov_base = (char *) iov[i].iov_base + w; + iov[i].iov_len -= w; + } else if (errno != EINTR && errno != EAGAIN) { + doerror(fb, B_WR); + rval = -1; + break; + } + + if (fb->flags & B_EOUT) { /* set asynchronously */ + rval = -1; + break; + } + } + } +#endif + } else + rval = -1; + + return rval; +} + + /* A wrapper for buff_write which deals with error conditions and * bytes_sent. Also handles non-blocking writes. */