diff options
author | bjh <bjh@13f79535-47bb-0310-9956-ffa450edef68> | 2001-03-05 14:51:59 +0000 |
---|---|---|
committer | bjh <bjh@13f79535-47bb-0310-9956-ffa450edef68> | 2001-03-05 14:51:59 +0000 |
commit | f1a020c6eaed360c2534dd7cd48787f2c168c959 (patch) | |
tree | ee37fccc829f7f41cf0a2a0baf6faa5026178b35 /network_io | |
parent | 0ba41ba67e090d8ef9c4c90fac75c76a40923829 (diff) | |
download | libapr-f1a020c6eaed360c2534dd7cd48787f2c168c959.tar.gz |
OS/2: Limit data passed to writev() to 64k as that's all it can handle.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61337 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r-- | network_io/os2/sendrecv.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/network_io/os2/sendrecv.c b/network_io/os2/sendrecv.c index 29b6190e2..fdb1ce77b 100644 --- a/network_io/os2/sendrecv.c +++ b/network_io/os2/sendrecv.c @@ -142,9 +142,15 @@ apr_status_t apr_sendv(apr_socket_t *sock, const struct iovec *vec, apr_int32_t apr_status_t rv; struct iovec *tmpvec; int fds, err = 0; + int nv_tosend, total = 0; - tmpvec = alloca(sizeof(struct iovec) * nvec); - memcpy(tmpvec, vec, sizeof(struct iovec) * nvec); + /* Make sure writev() only gets fed 64k at a time */ + for ( nv_tosend = 0; total + vec[nv_tosend].iov_len < 65536; nv_tosend++ ) { + total += vec[nv_tosend].iov_len; + } + + tmpvec = alloca(sizeof(struct iovec) * nv_tosend); + memcpy(tmpvec, vec, sizeof(struct iovec) * nv_tosend); do { if (!sock->nonblock || err == SOCEWOULDBLOCK) { @@ -165,7 +171,7 @@ apr_status_t apr_sendv(apr_socket_t *sock, const struct iovec *vec, apr_int32_t } } - rv = writev(sock->socketdes, tmpvec, nvec); + rv = writev(sock->socketdes, tmpvec, nv_tosend); err = rv < 0 ? sock_errno() : 0; } while (err == SOCEINTR || err == SOCEWOULDBLOCK); |