summaryrefslogtreecommitdiff
path: root/network_io/unix/sendrecv.c
diff options
context:
space:
mode:
authorThom May <thommay@apache.org>2002-11-20 03:50:23 +0000
committerThom May <thommay@apache.org>2002-11-20 03:50:23 +0000
commit79106b3bfe967386805002cd6952e8eb0bd4a274 (patch)
tree970704b99664fde6f1803a70c4287a9326c2b7c4 /network_io/unix/sendrecv.c
parent2479ef9e4fe9a3aca25b9cb8efc3beefa7e0c497 (diff)
downloadapr-79106b3bfe967386805002cd6952e8eb0bd4a274.tar.gz
*) Renames done (deprecated functions wrapped):
apr_filename_of_pathname -> apr_filepath_name_get apr_get_groupid -> apr_gid_get apr_get_groupname -> apr_gid_name_get apr_compare_groups -> apr_gid_compare apr_parse_addr_port -> apr_port_addr_parse apr_shutdown -> apr_socket_shutdown apr_bind -> apr_socket_bind apr_listen -> apr_socket_listen apr_accept -> apr_socket_accept apr_connect -> apr_socket_connect apr_send -> apr_socket_send apr_sendv -> apr_socket_sendv apr_sendto -> apr_socket_sendto apr_implode_gmt -> apr_time_exp_gmt_get apr_get_home_directory -> apr_uid_homepath_get apr_get_userid -> apr_uid_get apr_current_userid -> apr_uid_current apr_compare_users -> apr_uid_compare apr_get_username -> apr_uid_name_get apr_recvfrom -> apr_socket_recvfrom apr_sendfile -> apr_socket_sendfile apr_recv -> apr_socket_recv git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@64043 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io/unix/sendrecv.c')
-rw-r--r--network_io/unix/sendrecv.c160
1 files changed, 105 insertions, 55 deletions
diff --git a/network_io/unix/sendrecv.c b/network_io/unix/sendrecv.c
index 521ab533a..ac6e19714 100644
--- a/network_io/unix/sendrecv.c
+++ b/network_io/unix/sendrecv.c
@@ -65,7 +65,8 @@
#include <sys/sysctl.h>
#endif
-apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
+apr_status_t apr_socket_send(apr_socket_t *sock, const char *buf,
+ apr_size_t *len)
{
apr_ssize_t rv;
@@ -98,20 +99,20 @@ do_select:
return errno;
}
if (sock->timeout && rv < *len) {
- sock->netmask |= APR_INCOMPLETE_WRITE;
+ sock->netmask |= APR_INCOMPLETE_WRITE;
}
(*len) = rv;
return APR_SUCCESS;
}
-apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
+apr_status_t apr_socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
{
apr_ssize_t rv;
apr_status_t arv;
if (sock->netmask & APR_INCOMPLETE_READ) {
- sock->netmask &= ~APR_INCOMPLETE_READ;
- goto do_select;
+ sock->netmask &= ~APR_INCOMPLETE_READ;
+ goto do_select;
}
do {
@@ -121,7 +122,7 @@ apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
sock->timeout != 0) {
do_select:
- arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
+ arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
if (arv != APR_SUCCESS) {
*len = 0;
return arv;
@@ -137,7 +138,7 @@ do_select:
return errno;
}
if (sock->timeout && rv < *len) {
- sock->netmask |= APR_INCOMPLETE_READ;
+ sock->netmask |= APR_INCOMPLETE_READ;
}
(*len) = rv;
if (rv == 0) {
@@ -146,8 +147,9 @@ do_select:
return APR_SUCCESS;
}
-apr_status_t apr_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
- apr_int32_t flags, const char *buf, apr_size_t *len)
+apr_status_t apr_socket_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
+ apr_int32_t flags, const char *buf,
+ apr_size_t *len)
{
apr_ssize_t rv;
@@ -179,9 +181,9 @@ apr_status_t apr_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
return APR_SUCCESS;
}
-apr_status_t apr_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
- apr_int32_t flags, char *buf,
- apr_size_t *len)
+apr_status_t apr_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
+ apr_int32_t flags, char *buf,
+ apr_size_t *len)
{
apr_ssize_t rv;
@@ -216,8 +218,8 @@ apr_status_t apr_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
}
#ifdef HAVE_WRITEV
-apr_status_t apr_sendv(apr_socket_t * sock, const struct iovec *vec,
- apr_int32_t nvec, apr_size_t *len)
+apr_status_t apr_socket_sendv(apr_socket_t * sock, const struct iovec *vec,
+ apr_int32_t nvec, apr_size_t *len)
{
apr_ssize_t rv;
apr_size_t requested_len = 0;
@@ -256,7 +258,7 @@ do_select:
return errno;
}
if (sock->timeout && rv < requested_len) {
- sock->netmask |= APR_INCOMPLETE_WRITE;
+ sock->netmask |= APR_INCOMPLETE_WRITE;
}
(*len) = rv;
return APR_SUCCESS;
@@ -275,9 +277,9 @@ static apr_hdtr_t no_hdtr;
#if defined(__linux__) && defined(HAVE_WRITEV)
-apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
- apr_hdtr_t *hdtr, apr_off_t *offset, apr_size_t *len,
- apr_int32_t flags)
+apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
+ apr_hdtr_t *hdtr, apr_off_t *offset,
+ apr_size_t *len, apr_int32_t flags)
{
off_t off = *offset;
int rv, nbytes = 0, total_hdrbytes, i;
@@ -300,9 +302,10 @@ apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
}
/* Now write the headers */
- arv = apr_sendv(sock, hdtr->headers, hdtr->numheaders, &hdrbytes);
+ arv = apr_socket_sendv(sock, hdtr->headers, hdtr->numheaders,
+ &hdrbytes);
if (arv != APR_SUCCESS) {
- *len = 0;
+ *len = 0;
return errno;
}
nbytes += hdrbytes;
@@ -327,10 +330,10 @@ apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
}
do {
- rv = sendfile(sock->socketdes, /* socket */
- file->filedes, /* open file descriptor of the file to be sent */
- &off, /* where in the file to start */
- *len /* number of bytes to send */
+ rv = sendfile(sock->socketdes, /* socket */
+ file->filedes, /* open file descriptor of the file to be sent */
+ &off, /* where in the file to start */
+ *len /* number of bytes to send */
);
} while (rv == -1 && errno == EINTR);
@@ -338,23 +341,23 @@ apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
(errno == EAGAIN || errno == EWOULDBLOCK) &&
sock->timeout > 0) {
do_select:
- arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
- if (arv != APR_SUCCESS) {
- *len = 0;
- return arv;
- }
+ arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
+ if (arv != APR_SUCCESS) {
+ *len = 0;
+ return arv;
+ }
else {
do {
- rv = sendfile(sock->socketdes, /* socket */
- file->filedes, /* open file descriptor of the file to be sent */
- &off, /* where in the file to start */
- *len); /* number of bytes to send */
+ rv = sendfile(sock->socketdes, /* socket */
+ file->filedes, /* open file descriptor of the file to be sent */
+ &off, /* where in the file to start */
+ *len); /* number of bytes to send */
} while (rv == -1 && errno == EINTR);
}
}
if (rv == -1) {
- *len = nbytes;
+ *len = nbytes;
rv = errno;
apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0);
return rv;
@@ -389,10 +392,11 @@ do_select:
/* Now write the footers */
if (hdtr->numtrailers > 0) {
apr_size_t trbytes;
- arv = apr_sendv(sock, hdtr->trailers, hdtr->numtrailers, &trbytes);
+ arv = apr_socket_sendv(sock, hdtr->trailers, hdtr->numtrailers,
+ &trbytes);
nbytes += trbytes;
if (arv != APR_SUCCESS) {
- *len = nbytes;
+ *len = nbytes;
rv = errno;
apr_socket_opt_set(sock, APR_TCP_NOPUSH, 0);
return rv;
@@ -455,10 +459,11 @@ static int include_hdrs_in_length(void)
return 1;
#endif
}
+
/* Release 3.1 or greater */
-apr_status_t apr_sendfile(apr_socket_t * sock, apr_file_t * file,
- apr_hdtr_t * hdtr, apr_off_t * offset, apr_size_t * len,
- apr_int32_t flags)
+apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file,
+ apr_hdtr_t * hdtr, apr_off_t * offset,
+ apr_size_t * len, apr_int32_t flags)
{
off_t nbytes = 0;
int rv, i;
@@ -588,9 +593,9 @@ apr_status_t apr_sendfile(apr_socket_t * sock, apr_file_t * file,
* if nbytes == 0, the rest of the file (from offset) is sent
*/
-apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
- apr_hdtr_t *hdtr, apr_off_t *offset, apr_size_t *len,
- apr_int32_t flags)
+apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
+ apr_hdtr_t *hdtr, apr_off_t *offset,
+ apr_size_t *len, apr_int32_t flags)
{
int i;
apr_ssize_t rc;
@@ -700,7 +705,7 @@ apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
}
if (rc == -1) {
- *len = 0;
+ *len = 0;
return errno;
}
@@ -719,9 +724,9 @@ apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
* AIX - version 4.3.2 with APAR IX85388, or version 4.3.3 and above
* OS/390 - V2R7 and above
*/
-apr_status_t apr_sendfile(apr_socket_t * sock, apr_file_t * file,
- apr_hdtr_t * hdtr, apr_off_t * offset, apr_size_t * len,
- apr_int32_t flags)
+apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file,
+ apr_hdtr_t * hdtr, apr_off_t * offset,
+ apr_size_t * len, apr_int32_t flags)
{
int i, ptr, rv = 0;
void * hbuf=NULL, * tbuf=NULL;
@@ -865,9 +870,9 @@ do_select:
* 111298-01, 108529-09, 109473-06, 109235-04, 108996-02, 111296-01, 109026-04,
* 108992-13
*/
-apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
- apr_hdtr_t *hdtr, apr_off_t *offset, apr_size_t *len,
- apr_int32_t flags)
+apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
+ apr_hdtr_t *hdtr, apr_off_t *offset,
+ apr_size_t *len, apr_int32_t flags)
{
apr_status_t rv, arv;
apr_size_t nbytes;
@@ -980,7 +985,7 @@ apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
/* Update how much we sent */
*len = nbytes;
if (sock->timeout && (*len < requested_len)) {
- sock->netmask |= APR_INCOMPLETE_WRITE;
+ sock->netmask |= APR_INCOMPLETE_WRITE;
}
return APR_SUCCESS;
}
@@ -996,14 +1001,59 @@ apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
* apr_sendfile() doesn't work on the platform;
* this dummy version is just to get exports.c to compile/link
*/
-apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
- apr_hdtr_t *hdtr, apr_off_t *offset, apr_size_t *len,
- apr_int32_t flags); /* avoid warning for no proto */
+apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
+ apr_hdtr_t *hdtr, apr_off_t *offset,
+ apr_size_t *len, apr_int32_t flags);
+ /* avoid warning for no proto */
+
+apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
+ apr_hdtr_t *hdtr, apr_off_t *offset,
+ apr_size_t *len, apr_int32_t flags)
+{
+ return APR_ENOTIMPL;
+}
+#endif
+/* deprecated */
+apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
+{
+ return apr_socket_send(sock, buf, len);
+}
+
+/* deprecated */
+#ifdef HAVE_WRITEV
+apr_status_t apr_sendv(apr_socket_t * sock, const struct iovec *vec,
+ apr_int32_t nvec, apr_size_t *len)
+{
+ return apr_socket_sendv(sock, vec, nvec, len);
+}
+#endif
+
+/* deprecated */
+apr_status_t apr_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
+ apr_int32_t flags, const char *buf, apr_size_t *len)
+{
+ return apr_socket_sendto(sock, where, flags, buf, len);
+}
+
+/* deprecated */
+apr_status_t apr_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
+ apr_int32_t flags, char *buf,
+ apr_size_t *len)
+{
+ return apr_socket_recvfrom(from, sock, flags, buf, len);
+}
+
+/* deprecated */
apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
apr_hdtr_t *hdtr, apr_off_t *offset, apr_size_t *len,
apr_int32_t flags)
{
- return APR_ENOTIMPL;
+ return apr_socket_sendfile(sock, file, hdtr, offset, len, flags);
+}
+
+/* deprecated */
+apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
+{
+ return apr_socket_recv(sock, buf, len);
}
-#endif