diff options
author | bjh <bjh@13f79535-47bb-0310-9956-ffa450edef68> | 1999-10-29 13:36:29 +0000 |
---|---|---|
committer | bjh <bjh@13f79535-47bb-0310-9956-ffa450edef68> | 1999-10-29 13:36:29 +0000 |
commit | 0f505af4ff55d59f726926ab27b245b7117e0946 (patch) | |
tree | a4079c9d1370b89616e259d661ab48aae6f2fa25 /network_io/os2/sendrecv.c | |
parent | 27db225ce9e5d9a1cff329c4a37d6f3b1851adc4 (diff) | |
download | libapr-0f505af4ff55d59f726926ab27b245b7117e0946.tar.gz |
Add new APR function ap_sendv(), a writev for APR sockets.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@59422 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io/os2/sendrecv.c')
-rw-r--r-- | network_io/os2/sendrecv.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/network_io/os2/sendrecv.c b/network_io/os2/sendrecv.c index 70e539e12..dba119d20 100644 --- a/network_io/os2/sendrecv.c +++ b/network_io/os2/sendrecv.c @@ -134,3 +134,47 @@ ap_status_t ap_recv(struct socket_t *sock, char *buf, ap_ssize_t *len) return APR_SUCCESS; } + + +ap_status_t ap_sendv(ap_socket_t *sock, const struct iovec *vec, ap_int32_t nvec, ap_int32_t *nbytes) +{ + ap_status_t rv; + struct iovec *tmpvec; + + tmpvec = alloca(sizeof(struct iovec) * nvec); + memcpy(tmpvec, vec, sizeof(struct iovec) * nvec); + + do { + rv = writev(sock->socketdes, tmpvec, nvec); + } while (rv == -1 && sock_errno() == SOCEINTR); + + if (rv == -1 && sock_errno() == SOCEWOULDBLOCK && sock->timeout != 0) { + int fds; + int srv; + + do { + fds = sock->socketdes; + srv = select(&fds, 1, 0, 0, sock->timeout >= 0 ? sock->timeout*1000 : -1); + } while (srv == -1 && sock_errno() == SOCEINTR); + + if (srv == 0) { + return APR_TIMEUP; + } + else if (srv < 0) { + return os2errno(sock_errno()); + } + else { + do { + rv = writev(sock->socketdes, (struct iovec *)vec, nvec); + } while (rv == -1 && sock_errno() == SOCEINTR); + } + } + + if (rv < 0) { + *nbytes = 0; + return os2errno(sock_errno()); + } + + *nbytes = rv; + return APR_SUCCESS; +} |