You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Bill Stoddard <bi...@wstoddard.com> on 2001/11/08 16:32:45 UTC
[PATCH] APR Socket IOL
This patch is a first rough implementation of a socket iol in APR (from discussions with
Sander Striker a few months back).
Public API Changes:
No new APIs were created.
apr_socket_create() has an extra parameter, a pointer to an apr_socket_iol_t.
New Public Structures:
apr_socket_iol_t - contains pointers to callback functions.
Usage:
If you do not want to redirect socket calls and just use existing APR calls, use
apr_socket_create() thusly:
apr_socket_create(&new_sock, APR_INET, SOCKSTREAM, NULL, r->pool);
If you want to redirect socket calls:
/* Set up apr_socket_iol_t with pointers to specific calls you
* want to redirect
*/
apr_socket_iol_t *iol;
iol = apr_pcalloc(r->pool, sizeof(*iol));
iol->iol_socket_shutdown = pointer_to_your_shutdown_function;
iol->iol_socket_read = pointer_to_your_read_function;
iol->iol_socket_write = pointer_to_your_write_function;
...
...
apr_socket_create(&new_sock, APR_INET, SOCKSTREAM, iol, r->pool);
Comments:
This patch implements a single cross platform entry point for all the apr_socket_* calls
(see network_io/unix/aprsocketapi.c). Most of the code in this patch is accounting for
this.
I have tested this on Windows. I started modifying code in the Unix branch but it is
surely is broken.Haven't made any effort on the other network_io OS specific branches.
Comments?
Bill
Index: modules/proxy/proxy_connect.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_connect.c,v
retrieving revision 1.50
diff -u -r1.50 proxy_connect.c
--- modules/proxy/proxy_connect.c 2001/08/20 16:49:29 1.50
+++ modules/proxy/proxy_connect.c 2001/11/08 14:33:32
@@ -216,7 +216,7 @@
}
/* create a new socket */
- if ((rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, r->pool)) != APR_SUCCESS) {
+ if ((rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, NULL, r->pool)) !=
APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"proxy: error creating socket");
return HTTP_INTERNAL_SERVER_ERROR;
Index: modules/proxy/proxy_ftp.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_ftp.c,v
retrieving revision 1.81
diff -u -r1.81 proxy_ftp.c
--- modules/proxy/proxy_ftp.c 2001/10/08 19:25:35 1.81
+++ modules/proxy/proxy_ftp.c 2001/11/08 14:33:33
@@ -673,7 +673,7 @@
}
- if ((rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, r->pool)) != APR_SUCCESS) {
+ if ((rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, NULL, r->pool)) !=
APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"proxy: FTP: error creating socket");
return HTTP_INTERNAL_SERVER_ERROR;
@@ -1041,7 +1041,7 @@
"proxy: FTP: EPSV contacting remote host on port %d",
remote_port);
- if ((rv = apr_socket_create(&remote_sock, APR_INET, SOCK_STREAM, r->pool)) !=
APR_SUCCESS) {
+ if ((rv = apr_socket_create(&remote_sock, APR_INET, SOCK_STREAM, NULL, r->pool)) !=
APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"proxy: FTP: error creating EPSV socket");
return HTTP_INTERNAL_SERVER_ERROR;
@@ -1135,7 +1135,7 @@
"proxy: FTP: PASV contacting host %d.%d.%d.%d:%d",
h3, h2, h1, h0, pasvport);
- if ((rv = apr_socket_create(&remote_sock, APR_INET, SOCK_STREAM, r->pool)) !=
APR_SUCCESS) {
+ if ((rv = apr_socket_create(&remote_sock, APR_INET, SOCK_STREAM, NULL, r->pool)) !=
APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"proxy: error creating PASV socket");
return HTTP_INTERNAL_SERVER_ERROR;
@@ -1177,7 +1177,7 @@
apr_port_t local_port;
unsigned int h0, h1, h2, h3, p0, p1;
- if ((rv = apr_socket_create(&local_sock, APR_INET, SOCK_STREAM, r->pool)) !=
APR_SUCCESS) {
+ if ((rv = apr_socket_create(&local_sock, APR_INET, SOCK_STREAM, NULL, r->pool)) !=
APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"proxy: FTP: error creating local socket");
return HTTP_INTERNAL_SERVER_ERROR;
Index: modules/proxy/proxy_http.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_http.c,v
retrieving revision 1.106
diff -u -r1.106 proxy_http.c
--- modules/proxy/proxy_http.c 2001/11/05 23:06:55 1.106
+++ modules/proxy/proxy_http.c 2001/11/08 14:33:33
@@ -342,7 +342,7 @@
backend->connection = NULL;
/* see memory note above */
- if ((rv = apr_socket_create(&p_conn->sock, APR_INET, SOCK_STREAM,
+ if ((rv = apr_socket_create(&p_conn->sock, APR_INET, SOCK_STREAM, NULL,
c->pool)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
"proxy: error creating socket");
Index: server/listen.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/listen.c,v
retrieving revision 1.63
diff -u -r1.63 listen.c
--- server/listen.c 2001/10/16 18:45:15 1.63
+++ server/listen.c 2001/11/08 14:33:33
@@ -191,7 +191,7 @@
if (default_family == APR_UNSPEC) {
apr_socket_t *tmp_sock;
- if (apr_socket_create(&tmp_sock, APR_INET6, SOCK_STREAM,
+ if (apr_socket_create(&tmp_sock, APR_INET6, SOCK_STREAM, NULL,
p) == APR_SUCCESS) {
apr_socket_close(tmp_sock);
default_family = APR_INET6;
@@ -254,7 +254,7 @@
return;
}
if ((status = apr_socket_create(&new->sd, new->bind_addr->sa.sin.sin_family,
- SOCK_STREAM, process->pool)) != APR_SUCCESS) {
+ SOCK_STREAM, NULL, process->pool)) != APR_SUCCESS) {
ap_log_perror(APLOG_MARK, APLOG_CRIT, status, process->pool,
"alloc_listener: failed to get a socket for %s", addr);
return;
Index: server/rfc1413.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/rfc1413.c,v
retrieving revision 1.43
diff -u -r1.43 rfc1413.c
--- server/rfc1413.c 2001/10/22 13:04:12 1.43
+++ server/rfc1413.c 2001/11/08 14:33:34
@@ -141,7 +141,7 @@
if ((rv = apr_socket_create(newsock,
localsa->sa.sin.sin_family, /* has to match */
- SOCK_STREAM, conn->pool)) != APR_SUCCESS) {
+ SOCK_STREAM, NULL, conn->pool)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, srv,
"rfc1413: error creating query socket");
return rv;
Index: srclib/apr/apr.dsp
===================================================================
RCS file: /home/cvs/apr/apr.dsp,v
retrieving revision 1.86
diff -u -r1.86 apr.dsp
--- srclib/apr/apr.dsp 2001/09/28 14:05:22 1.86
+++ srclib/apr/apr.dsp 2001/11/08 14:33:34
@@ -101,10 +101,6 @@
# End Source File
# Begin Source File
-SOURCE=.\file_io\unix\mktemp.c
-# End Source File
-# Begin Source File
-
SOURCE=.\file_io\unix\fileacc.c
# End Source File
# Begin Source File
@@ -133,6 +129,10 @@
# End Source File
# Begin Source File
+SOURCE=.\file_io\unix\mktemp.c
+# End Source File
+# Begin Source File
+
SOURCE=.\file_io\win32\open.c
# End Source File
# Begin Source File
@@ -240,6 +240,10 @@
# Begin Group "network_io"
# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\network_io\unix\aprsockapi.c
+# End Source File
# Begin Source File
SOURCE=.\network_io\unix\inet_ntop.c
Index: srclib/apr/libapr.dsp
===================================================================
RCS file: /home/cvs/apr/libapr.dsp,v
retrieving revision 1.46
diff -u -r1.46 libapr.dsp
--- srclib/apr/libapr.dsp 2001/09/28 14:05:23 1.46
+++ srclib/apr/libapr.dsp 2001/11/08 14:33:34
@@ -244,6 +244,10 @@
# PROP Default_Filter ""
# Begin Source File
+SOURCE=.\network_io\unix\aprsockapi.c
+# End Source File
+# Begin Source File
+
SOURCE=.\network_io\unix\inet_ntop.c
# End Source File
# Begin Source File
Index: srclib/apr/include/apr_network_io.h
===================================================================
RCS file: /home/cvs/apr/include/apr_network_io.h,v
retrieving revision 1.111
diff -u -r1.111 apr_network_io.h
--- srclib/apr/include/apr_network_io.h 2001/08/15 21:02:53 1.111
+++ srclib/apr/include/apr_network_io.h 2001/11/08 14:33:34
@@ -185,6 +185,7 @@
#endif
typedef struct apr_socket_t apr_socket_t;
+typedef struct apr_socket_iol_t apr_socket_iol_t;
typedef struct apr_pollfd_t apr_pollfd_t;
/**
* A structure to encapsulate headers and trailers for apr_sendfile
@@ -279,7 +280,8 @@
*/
APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new_sock,
int family, int type,
- apr_pool_t *cont);
+ apr_socket_iol_t *iol,
+ apr_pool_t *p);
/**
* Shutdown either reading, writing, or both sides of a tcp socket.
@@ -814,6 +816,117 @@
*/
APR_DECLARE(void) apr_socket_unset_inherit(apr_socket_t *skt);
+
+/*
+ * Socket IOL
+ */
+
+
+typedef apr_status_t (*apr_socket_create_fn_t) (apr_socket_t **new_sock,
+ int family, int type,
+ apr_pool_t *p);
+typedef apr_status_t (*apr_shutdown_fn_t) (apr_socket_t *thesocket,
+ apr_shutdown_how_e how);
+typedef apr_status_t (*apr_socket_close_fn_t) (apr_socket_t *thesocket);
+typedef apr_status_t (*apr_bind_fn_t) (apr_socket_t *sock, apr_sockaddr_t *sa);
+typedef apr_status_t (*apr_listen_fn_t) (apr_socket_t *sock, apr_int32_t backlog);
+typedef apr_status_t (*apr_accept_fn_t) (apr_socket_t **new_sock,
+ apr_socket_t *sock,
+ apr_pool_t *connection_pool);
+typedef apr_status_t (*apr_connect_fn_t) (apr_socket_t *sock, apr_sockaddr_t *sa);
+typedef apr_status_t (*apr_socket_data_get_fn_t) (void **data, const char *key,
+ apr_socket_t *sock);
+typedef apr_status_t (*apr_socket_data_set_fn_t) (apr_socket_t *sock, void *data,
+ const char *key,
+ apr_status_t (*cleanup)(void*));
+typedef apr_status_t (*apr_send_fn_t) (apr_socket_t *sock, const char *buf,
+ apr_size_t *len);
+typedef apr_status_t (*apr_sendv_fn_t) (apr_socket_t *sock,
+ const struct iovec *vec,
+ apr_int32_t nvec, apr_size_t *len);
+typedef apr_status_t (*apr_sendto_fn_t) (apr_socket_t *sock, apr_sockaddr_t *where,
+ apr_int32_t flags, const char *buf,
+ apr_size_t *len);
+typedef apr_status_t (*apr_recvfrom_fn_t) (apr_sockaddr_t *from, apr_socket_t *sock,
+ apr_int32_t flags, char *buf,
+ apr_size_t *len);
+#if APR_HAS_SENDFILE
+typedef apr_status_t (*apr_sendfile_fn_t) (apr_socket_t *sock, apr_file_t *file,
+ apr_hdtr_t *hdtr, apr_off_t *offset,
+ apr_size_t *len, apr_int32_t flags);
+#endif /* APR_HAS_SENDFILE */
+typedef apr_status_t (*apr_recv_fn_t) (apr_socket_t *sock,
+ char *buf, apr_size_t *len);
+typedef apr_status_t (*apr_setsocketopt_fn_t) (apr_socket_t *sock,
+ apr_int32_t opt, apr_int32_t on);
+typedef apr_status_t (*apr_getsocketopt_fn_t) (apr_socket_t *sock,
+ apr_int32_t opt, apr_int32_t *on);
+typedef apr_status_t (*apr_socket_addr_get_fn_t) (apr_sockaddr_t **sa,
+ apr_interface_e which,
+ apr_socket_t *sock);
+typedef apr_status_t (*apr_poll_socket_add_fn_t) (apr_pollfd_t *aprset,
+ apr_socket_t *sock,
+ apr_int16_t event);
+typedef apr_status_t (*apr_poll_socket_mask_fn_t) (apr_pollfd_t *aprset,
+ apr_socket_t *sock,
+ apr_int16_t events);
+typedef apr_status_t (*apr_poll_socket_remove_fn_t) (apr_pollfd_t *aprset,
+ apr_socket_t *sock);
+typedef apr_status_t (*apr_poll_socket_clear_fn_t) (apr_pollfd_t *aprset,
+ apr_int16_t events);
+typedef apr_status_t (*apr_poll_revents_get_fn_t) (apr_int16_t *event,
+ apr_socket_t *sock,
+ apr_pollfd_t *aprset);
+#if APR_FILES_AS_SOCKETS
+typedef apr_status_t (*apr_socket_from_file_fn_t) (apr_socket_t **newsock,
+ apr_file_t *file);
+#endif /* APR_FILES_AS_SOCKETS */
+typedef void (*apr_socket_set_inherit_fn_t) (apr_socket_t *sock);
+typedef void (*apr_socket_unset_inherit_fn_t) (apr_socket_t *sock);
+#if APR_HAS_SO_ACCEPTFILTER
+typedef apr_status_t (*apr_socket_accept_filter_fn_t) (apr_socket_t *sock, char *name,
+ char *args);
+#endif
+
+
+struct apr_socket_iol_t
+{
+ apr_socket_create_fn_t iol_socket_create;
+ apr_shutdown_fn_t iol_socket_shutdown;
+ apr_socket_close_fn_t iol_socket_close;
+ apr_bind_fn_t iol_socket_bind;
+ apr_listen_fn_t iol_socket_listen;
+ apr_accept_fn_t iol_socket_accept;
+ apr_connect_fn_t iol_socket_connect;
+ apr_socket_data_get_fn_t iol_socket_data_get;
+ apr_socket_data_set_fn_t iol_socket_data_set;
+ apr_send_fn_t iol_socket_send;
+ apr_sendv_fn_t iol_socket_sendv;
+ apr_sendto_fn_t iol_socket_sendto;
+ apr_recvfrom_fn_t iol_socket_recvfrom;
+#if APR_HAS_SENDFILE
+ apr_sendfile_fn_t iol_socket_sendfile;
+#endif /* APR_HAS_SENDFILE */
+ apr_recv_fn_t iol_socket_recv;
+ apr_setsocketopt_fn_t iol_socket_setsocketopt;
+ apr_getsocketopt_fn_t iol_socket_getsocketopt;
+ apr_socket_addr_get_fn_t iol_socket_addr_get;
+
+ /* Poll socket calls */
+ apr_poll_socket_add_fn_t iol_socket_poll_socket_add;
+ apr_poll_socket_mask_fn_t iol_socket_poll_socket_mask;
+ apr_poll_socket_remove_fn_t iol_socket_poll_socket_remove;
+ apr_poll_socket_clear_fn_t iol_socket_poll_socket_clear;
+ apr_poll_revents_get_fn_t iol_socket_poll_revents_get;
+ apr_socket_set_inherit_fn_t iol_socket_set_inherit;
+ apr_socket_unset_inherit_fn_t iol_socket_unset_inherit;
+#if APR_HAS_SO_ACCEPTFILTER
+ apr_socket_accept_filter_fn_t iol_socket_accept_filter;
+#endif
+#if APR_FILES_AS_SOCKETS
+ apr_socket_from_file_fn_t iol_socket_from_file;
+#endif /* APR_FILES_AS_SOCKETS */
+};
#ifdef __cplusplus
}
#endif
Index: srclib/apr/include/arch/unix/networkio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/unix/networkio.h,v
retrieving revision 1.48
diff -u -r1.48 networkio.h
--- srclib/apr/include/arch/unix/networkio.h 2001/07/16 20:36:59 1.48
+++ srclib/apr/include/arch/unix/networkio.h 2001/11/08 14:33:34
@@ -136,6 +136,7 @@
int local_interface_unknown;
apr_int32_t netmask;
apr_int32_t inherit;
+ apr_socket_iol_t *iol;
};
struct apr_pollfd_t {
Index: srclib/apr/include/arch/win32/networkio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/win32/networkio.h,v
retrieving revision 1.20
diff -u -r1.20 networkio.h
--- srclib/apr/include/arch/win32/networkio.h 2001/07/16 20:37:00 1.20
+++ srclib/apr/include/arch/win32/networkio.h 2001/11/08 14:33:34
@@ -70,6 +70,7 @@
int local_interface_unknown;
apr_int32_t netmask;
apr_int32_t inherit;
+ apr_socket_iol_t *iol;
};
struct apr_pollfd_t {
Index: srclib/apr/network_io/unix/poll.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/poll.c,v
retrieving revision 1.49
diff -u -r1.49 poll.c
--- srclib/apr/network_io/unix/poll.c 2001/10/02 18:51:17 1.49
+++ srclib/apr/network_io/unix/poll.c 2001/11/08 14:33:34
@@ -57,7 +57,7 @@
#ifdef HAVE_POLL /* We can just use poll to do our socket polling. */
-apr_status_t apr_poll_setup(apr_pollfd_t **new, apr_int32_t num, apr_pool_t *cont)
+apr_status_t socket_poll_setup(apr_pollfd_t **new, apr_int32_t num, apr_pool_t *cont)
{
(*new) = (apr_pollfd_t *)apr_pcalloc(cont, sizeof(apr_pollfd_t));
if ((*new) == NULL) {
@@ -115,7 +115,7 @@
return rv;
}
-apr_status_t apr_poll_socket_add(apr_pollfd_t *aprset,
+apr_status_t socket_poll_socket_add(apr_pollfd_t *aprset,
apr_socket_t *sock, apr_int16_t event)
{
int i = 0;
@@ -135,7 +135,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_poll(apr_pollfd_t *aprset, apr_int32_t *nsds,
+apr_status_t socket_poll(apr_pollfd_t *aprset, apr_int32_t *nsds,
apr_interval_time_t timeout)
{
int rv;
@@ -153,7 +153,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_poll_revents_get(apr_int16_t *event, apr_socket_t *sock, apr_pollfd_t
*aprset)
+apr_status_t socket_poll_revents_get(apr_int16_t *event, apr_socket_t *sock, apr_pollfd_t
*aprset)
{
int i = 0;
@@ -167,7 +167,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_poll_socket_mask(apr_pollfd_t *aprset,
+apr_status_t socket_poll_socket_mask(apr_pollfd_t *aprset,
apr_socket_t *sock, apr_int16_t events)
{
apr_int16_t newevents;
@@ -187,7 +187,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_poll_socket_remove(apr_pollfd_t *aprset, apr_socket_t *sock)
+apr_status_t socket_poll_socket_remove(apr_pollfd_t *aprset, apr_socket_t *sock)
{
int i = 0;
while(i < aprset->curpos && aprset->pollset[i].fd != sock->socketdes) {
@@ -204,7 +204,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_poll_socket_clear(apr_pollfd_t *aprset, apr_int16_t events)
+apr_status_t socket_poll_socket_clear(apr_pollfd_t *aprset, apr_int16_t events)
{
int i = 0;
apr_int16_t newevents;
@@ -222,7 +222,7 @@
#else /* Use select to mimic poll */
-apr_status_t apr_poll_setup(apr_pollfd_t **new, apr_int32_t num, apr_pool_t *cont)
+apr_status_t socket_poll_setup(apr_pollfd_t **new, apr_int32_t num, apr_pool_t *cont)
{
(*new) = (apr_pollfd_t *)apr_pcalloc(cont, sizeof(apr_pollfd_t) * num);
if ((*new) == NULL) {
@@ -245,7 +245,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_poll_socket_add(apr_pollfd_t *aprset,
+apr_status_t socket_poll_socket_add(apr_pollfd_t *aprset,
apr_socket_t *sock, apr_int16_t event)
{
if (event & APR_POLLIN) {
@@ -263,7 +263,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_poll_socket_mask(apr_pollfd_t *aprset,
+apr_status_t socket_poll_socket_mask(apr_pollfd_t *aprset,
apr_socket_t *sock,
apr_int16_t events)
{
@@ -279,7 +279,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_poll(apr_pollfd_t *aprset, apr_int32_t *nsds,
+apr_status_t socket_poll(apr_pollfd_t *aprset, apr_int32_t *nsds,
apr_interval_time_t timeout)
{
int rv;
@@ -311,7 +311,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_poll_revents_get(apr_int16_t *event, apr_socket_t *sock, apr_pollfd_t
*aprset)
+apr_status_t socket_poll_revents_get(apr_int16_t *event, apr_socket_t *sock, apr_pollfd_t
*aprset)
{
apr_int16_t revents = 0;
char data[1];
@@ -358,7 +358,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_poll_socket_remove(apr_pollfd_t *aprset, apr_socket_t *sock)
+apr_status_t socket_poll_socket_remove(apr_pollfd_t *aprset, apr_socket_t *sock)
{
FD_CLR(sock->socketdes, aprset->read_set);
FD_CLR(sock->socketdes, aprset->except_set);
@@ -366,7 +366,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_poll_socket_clear(apr_pollfd_t *aprset, apr_int16_t event)
+apr_status_t socket_poll_socket_clear(apr_pollfd_t *aprset, apr_int16_t event)
{
if (event & APR_POLLIN) {
FD_ZERO(aprset->read_set);
@@ -383,12 +383,12 @@
#endif
-apr_status_t apr_poll_data_get(apr_pollfd_t *pollfd, const char *key, void *data)
+apr_status_t socket_poll_data_get(apr_pollfd_t *pollfd, const char *key, void *data)
{
return apr_pool_userdata_get(data, key, pollfd->cntxt);
}
-apr_status_t apr_poll_data_set(apr_pollfd_t *pollfd, void *data, const char *key,
+apr_status_t socket_poll_data_set(apr_pollfd_t *pollfd, void *data, const char *key,
apr_status_t (*cleanup) (void *))
{
return apr_pool_userdata_set(data, key, cleanup, pollfd->cntxt);
@@ -399,7 +399,7 @@
* for right now, we'll leave it this way, and change it later if
* necessary.
*/
-apr_status_t apr_socket_from_file(apr_socket_t **newsock, apr_file_t *file)
+apr_status_t socket_from_file(apr_socket_t **newsock, apr_file_t *file)
{
(*newsock) = apr_pcalloc(file->cntxt, sizeof(**newsock));
(*newsock)->socketdes = file->filedes;
Index: srclib/apr/network_io/unix/sa_common.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sa_common.c,v
retrieving revision 1.45
diff -u -r1.45 sa_common.c
--- srclib/apr/network_io/unix/sa_common.c 2001/09/12 19:46:12 1.45
+++ srclib/apr/network_io/unix/sa_common.c 2001/11/08 14:33:34
@@ -89,8 +89,8 @@
#define GETHOSTBYNAME_BUFLEN 512
#endif
-APR_DECLARE(apr_status_t) apr_sockaddr_port_set(apr_sockaddr_t *sockaddr,
- apr_port_t port)
+APR_DECLARE(apr_status_t) apr_sockaddr_port_set(apr_sockaddr_t *sockaddr,
+ apr_port_t port)
{
sockaddr->port = port;
/* XXX IPv6: assumes sin_port and sin6_port at same offset */
@@ -102,8 +102,7 @@
* since we have apr_sockaddr_info_get(), but we need to clean up Apache's
* listen.c a bit more first.
*/
-APR_DECLARE(apr_status_t) apr_sockaddr_ip_set(apr_sockaddr_t *sockaddr,
- const char *addr)
+APR_DECLARE(apr_status_t) apr_sockaddr_ip_set(apr_sockaddr_t *sockaddr, const char *addr)
{
apr_uint32_t ipaddr;
@@ -125,16 +124,16 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_sockaddr_port_get(apr_port_t *port,
- apr_sockaddr_t *sockaddr)
+APR_DECLARE(apr_status_t) apr_sockaddr_port_get(apr_port_t *port,
+ apr_sockaddr_t *sockaddr)
{
/* XXX IPv6 - assumes sin_port and sin6_port at same offset */
*port = ntohs(sockaddr->sa.sin.sin_port);
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr,
- apr_sockaddr_t *sockaddr)
+APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr,
+ apr_sockaddr_t *sockaddr)
{
*addr = apr_palloc(sockaddr->pool, sockaddr->addr_str_len);
apr_inet_ntop(sockaddr->sa.sin.sin_family,
@@ -177,9 +176,8 @@
#endif
}
-APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa,
- apr_interface_e which,
- apr_socket_t *sock)
+apr_status_t socket_addr_get(apr_sockaddr_t **sa, apr_interface_e which,
+ apr_socket_t *sock)
{
if (which == APR_LOCAL) {
if (sock->local_interface_unknown || sock->local_port_unknown) {
@@ -327,9 +325,9 @@
#endif
APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa,
- const char *hostname,
- apr_int32_t family, apr_port_t port,
- apr_int32_t flags, apr_pool_t *p)
+ const char *hostname,
+ apr_int32_t family, apr_port_t port,
+ apr_int32_t flags, apr_pool_t *p)
{
(*sa) = (apr_sockaddr_t *)apr_pcalloc(p, sizeof(apr_sockaddr_t));
if ((*sa) == NULL)
@@ -582,8 +580,8 @@
#endif
}
-APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr,
- const char *servname)
+APR_DECLARE(apr_status_t) socket_getservbyname(apr_sockaddr_t *sockaddr,
+ const char *servname)
{
struct servent *se;
Index: srclib/apr/network_io/unix/sendrecv.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sendrecv.c,v
retrieving revision 1.76
diff -u -r1.76 sendrecv.c
--- srclib/apr/network_io/unix/sendrecv.c 2001/08/22 19:23:24 1.76
+++ srclib/apr/network_io/unix/sendrecv.c 2001/11/08 14:33:34
@@ -52,6 +52,7 @@
* <http://www.apache.org/>.
*/
+#incluide "apr_network_io.h"
#include "networkio.h"
#if APR_HAS_SENDFILE
@@ -93,7 +94,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
+apr_status_t socket_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
{
ssize_t rv;
@@ -122,7 +123,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
+apr_status_t socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
{
ssize_t rv;
apr_status_t arv;
@@ -164,7 +165,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
+apr_status_t socket_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
apr_int32_t flags, const char *buf, apr_size_t *len)
{
ssize_t rv;
@@ -197,7 +198,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
+apr_status_t socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
apr_int32_t flags, char *buf,
apr_size_t *len)
{
@@ -234,8 +235,8 @@
}
#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 socket_sendv(apr_socket_t * sock, const struct iovec *vec,
+ apr_int32_t nvec, apr_size_t *len)
{
apr_ssize_t rv;
@@ -277,7 +278,7 @@
#if defined(__linux__) && defined(HAVE_WRITEV)
-apr_status_t apr_sendfile(apr_socket_t *sock, apr_file_t *file,
+apr_status_t 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)
{
@@ -389,7 +390,7 @@
#elif defined(__FreeBSD__)
/* Release 3.1 or greater */
-apr_status_t apr_sendfile(apr_socket_t * sock, apr_file_t * file,
+apr_status_t 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)
{
@@ -493,7 +494,7 @@
* 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_status_t 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)
{
@@ -624,7 +625,7 @@
* 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_status_t 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)
{
@@ -758,7 +759,7 @@
* 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_status_t 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)
{
@@ -870,11 +871,11 @@
* 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_status_t 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_sendfile(apr_socket_t *sock, apr_file_t *file,
+apr_status_t 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)
{
Index: srclib/apr/network_io/unix/sockets.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sockets.c,v
retrieving revision 1.87
diff -u -r1.87 sockets.c
--- srclib/apr/network_io/unix/sockets.c 2001/08/08 05:48:58 1.87
+++ srclib/apr/network_io/unix/sockets.c 2001/11/08 14:33:35
@@ -126,7 +126,7 @@
(*new)->remote_addr->pool = p;
}
-apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type,
+apr_status_t socket_create(apr_socket_t **new, int ofamily, int type,
apr_pool_t *cont)
{
int family = ofamily;
@@ -166,18 +166,18 @@
return APR_SUCCESS;
}
-apr_status_t apr_shutdown(apr_socket_t *thesocket, apr_shutdown_how_e how)
+apr_status_t socket_shutdown(apr_socket_t *thesocket, apr_shutdown_how_e how)
{
return (shutdown(thesocket->socketdes, how) == -1) ? errno : APR_SUCCESS;
}
-apr_status_t apr_socket_close(apr_socket_t *thesocket)
+apr_status_t socket_close(apr_socket_t *thesocket)
{
apr_pool_cleanup_kill(thesocket->cntxt, thesocket, socket_cleanup);
return socket_cleanup(thesocket);
}
-apr_status_t apr_bind(apr_socket_t *sock, apr_sockaddr_t *sa)
+apr_status_t socket_bind(apr_socket_t *sock, apr_sockaddr_t *sa)
{
if (bind(sock->socketdes,
(struct sockaddr *)&sa->sa, sa->salen) == -1) {
@@ -193,7 +193,7 @@
}
}
-apr_status_t apr_listen(apr_socket_t *sock, apr_int32_t backlog)
+apr_status_t socket_listen(apr_socket_t *sock, apr_int32_t backlog)
{
if (listen(sock->socketdes, backlog) == -1)
return errno;
@@ -201,7 +201,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_accept(apr_socket_t **new, apr_socket_t *sock, apr_pool_t
*connection_context)
+apr_status_t socket_accept(apr_socket_t **new, apr_socket_t *sock, apr_pool_t
*connection_context)
{
alloc_socket(new, connection_context);
set_socket_vars(*new, sock->local_addr->sa.sin.sin_family, SOCK_STREAM);
@@ -259,7 +259,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
+apr_status_t socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
{
int rc;
@@ -315,12 +315,12 @@
return APR_SUCCESS;
}
-apr_status_t apr_socket_data_get(void **data, const char *key, apr_socket_t *sock)
+apr_status_t socket_data_get(void **data, const char *key, apr_socket_t *sock)
{
return apr_pool_userdata_get(data, key, sock->cntxt);
}
-apr_status_t apr_socket_data_set(apr_socket_t *sock, void *data, const char *key,
+apr_status_t socket_data_set(apr_socket_t *sock, void *data, const char *key,
apr_status_t (*cleanup) (void *))
{
return apr_pool_userdata_set(data, key, cleanup, sock->cntxt);
Index: srclib/apr/network_io/unix/sockopt.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sockopt.c,v
retrieving revision 1.48
diff -u -r1.48 sockopt.c
--- srclib/apr/network_io/unix/sockopt.c 2001/07/30 17:56:16 1.48
+++ srclib/apr/network_io/unix/sockopt.c 2001/11/08 14:33:35
@@ -110,7 +110,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_setsocketopt(apr_socket_t *sock, apr_int32_t opt, apr_int32_t on)
+apr_status_t socket_setsocketopt(apr_socket_t *sock, apr_int32_t opt, apr_int32_t on)
{
int one;
apr_status_t stat;
@@ -279,7 +279,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_getsocketopt(apr_socket_t *sock, apr_int32_t opt, apr_int32_t *on)
+apr_status_t socket_getsocketopt(apr_socket_t *sock, apr_int32_t opt, apr_int32_t *on)
{
switch(opt) {
case APR_SO_TIMEOUT:
@@ -291,7 +291,7 @@
return APR_SUCCESS;
}
-apr_status_t apr_gethostname(char *buf, apr_int32_t len, apr_pool_t *cont)
+apr_status_t socket_gethostname(char *buf, apr_int32_t len, apr_pool_t *cont)
{
if (gethostname(buf, len) == -1)
return errno;
@@ -300,7 +300,7 @@
}
#if APR_HAS_SO_ACCEPTFILTER
-apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name,
+apr_status_t socket_accept_filter(apr_socket_t *sock, char *name,
char *args)
{
struct accept_filter_arg af;
Index: srclib/apr/network_io/win32/poll.c
===================================================================
RCS file: /home/cvs/apr/network_io/win32/poll.c,v
retrieving revision 1.28
diff -u -r1.28 poll.c
--- srclib/apr/network_io/win32/poll.c 2001/08/06 16:15:04 1.28
+++ srclib/apr/network_io/win32/poll.c 2001/11/08 14:33:35
@@ -60,7 +60,7 @@
#include <time.h>
-APR_DECLARE(apr_status_t) apr_poll_setup(apr_pollfd_t **new, apr_int32_t num,
+APR_DECLARE(apr_status_t) apr_poll_setup(apr_pollfd_t **new, apr_int32_t num,
apr_pool_t *cont)
{
(*new) = (apr_pollfd_t *)apr_palloc(cont, sizeof(apr_pollfd_t) * num);
@@ -80,9 +80,8 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_poll_socket_add(apr_pollfd_t *aprset,
- apr_socket_t *sock,
- apr_int16_t event)
+apr_status_t socket_poll_socket_add(apr_pollfd_t *aprset, apr_socket_t *sock,
+ apr_int16_t event)
{
if (event & APR_POLLIN) {
FD_SET(sock->sock, aprset->read);
@@ -146,9 +145,9 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_poll_revents_get(apr_int16_t *event,
- apr_socket_t *sock,
- apr_pollfd_t *aprset)
+apr_status_t socket_poll_revents_get(apr_int16_t *event,
+ apr_socket_t *sock,
+ apr_pollfd_t *aprset)
{
apr_int16_t revents = 0;
WSABUF data;
@@ -204,21 +203,21 @@
}
APR_DECLARE(apr_status_t) apr_poll_data_get(apr_pollfd_t *pollfd,
- const char *key, void *data)
+ const char *key, void *data)
{
return apr_pool_userdata_get(data, key, pollfd->cntxt);
}
APR_DECLARE(apr_status_t) apr_poll_data_set(apr_pollfd_t *pollfd, void *data,
- const char *key,
- apr_status_t (*cleanup)(void *))
+ const char *key,
+ apr_status_t (*cleanup)(void *))
{
return apr_pool_userdata_set(data, key, cleanup, pollfd->cntxt);
}
-APR_DECLARE(apr_status_t) apr_poll_socket_mask(apr_pollfd_t *aprset,
- apr_socket_t *sock,
- apr_int16_t events)
+apr_status_t socket_poll_socket_mask(apr_pollfd_t *aprset,
+ apr_socket_t *sock,
+ apr_int16_t events)
{
if (events & APR_POLLIN) {
FD_CLR(sock->sock, aprset->read);
@@ -235,14 +234,14 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_poll_socket_remove(apr_pollfd_t *aprset,
- apr_socket_t *sock)
+apr_status_t socket_poll_socket_remove(apr_pollfd_t *aprset,
+ apr_socket_t *sock)
{
- return apr_poll_socket_mask(aprset, sock, ~0);
+ return socket_poll_socket_mask(aprset, sock, ~0);
}
APR_DECLARE(apr_status_t) apr_poll_socket_clear(apr_pollfd_t *aprset,
- apr_int16_t events)
+ apr_int16_t events)
{
if (events & APR_POLLIN) {
FD_ZERO(aprset->read);
Index: srclib/apr/network_io/win32/sendrecv.c
===================================================================
RCS file: /home/cvs/apr/network_io/win32/sendrecv.c,v
retrieving revision 1.43
diff -u -r1.43 sendrecv.c
--- srclib/apr/network_io/win32/sendrecv.c 2001/08/19 02:05:04 1.43
+++ srclib/apr/network_io/win32/sendrecv.c 2001/11/08 14:33:35
@@ -71,8 +71,7 @@
#define MAX_SEGMENT_SIZE 65536
#define WSABUF_ON_STACK 50
-APR_DECLARE(apr_status_t) apr_send(apr_socket_t *sock, const char *buf,
- apr_size_t *len)
+apr_status_t socket_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
{
apr_ssize_t rv;
WSABUF wsaData;
@@ -93,9 +92,7 @@
return APR_SUCCESS;
}
-
-APR_DECLARE(apr_status_t) apr_recv(apr_socket_t *sock, char *buf,
- apr_size_t *len)
+apr_status_t socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
{
apr_ssize_t rv;
WSABUF wsaData;
@@ -117,11 +114,10 @@
return APR_SUCCESS;
}
-
-APR_DECLARE(apr_status_t) apr_sendv(apr_socket_t *sock,
- const struct iovec *vec,
- apr_int32_t nvec, apr_size_t *nbytes)
+apr_status_t socket_sendv(apr_socket_t *sock,
+ const struct iovec *vec,
+ apr_int32_t nvec, apr_size_t *nbytes)
{
apr_status_t rc = APR_SUCCESS;
apr_ssize_t rv;
@@ -153,9 +149,9 @@
}
-APR_DECLARE(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 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;
@@ -171,11 +167,10 @@
return APR_SUCCESS;
}
-
-APR_DECLARE(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 socket_recvfrom(apr_sockaddr_t *from,
+ apr_socket_t *sock,
+ apr_int32_t flags,
+ char *buf, apr_size_t *len)
{
apr_ssize_t rv;
@@ -192,7 +187,6 @@
return APR_SUCCESS;
}
-
static void collapse_iovec(char **buf, int *len, struct iovec *iovec, int numvec,
apr_pool_t *p)
{
int ptr = 0;
@@ -240,9 +234,9 @@
* arg 5) Number of bytes to send out of the file
* arg 6) APR flags that are mapped to OS specific flags
*/
-APR_DECLARE(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 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 status = APR_SUCCESS;
apr_ssize_t rv;
@@ -266,13 +260,13 @@
/* Handle the goofy case of sending headers/trailers and a zero byte file */
if (!bytes_to_send && hdtr) {
if (hdtr->numheaders) {
- rv = apr_sendv(sock, hdtr->headers, hdtr->numheaders, &nbytes);
+ rv = socket_sendv(sock, hdtr->headers, hdtr->numheaders, &nbytes); file://WGS
if (rv != APR_SUCCESS)
return rv;
*len += nbytes;
}
if (hdtr->numtrailers) {
- rv = apr_sendv(sock, hdtr->trailers, hdtr->numtrailers, &nbytes);
+ rv = socket_sendv(sock, hdtr->trailers, hdtr->numtrailers, &nbytes);
if (rv != APR_SUCCESS)
return rv;
*len += nbytes;
Index: srclib/apr/network_io/win32/sockets.c
===================================================================
RCS file: /home/cvs/apr/network_io/win32/sockets.c,v
retrieving revision 1.65
diff -u -r1.65 sockets.c
--- srclib/apr/network_io/win32/sockets.c 2001/08/09 23:28:38 1.65
+++ srclib/apr/network_io/win32/sockets.c 2001/11/08 14:33:35
@@ -117,8 +117,8 @@
(*new)->remote_addr->pool = p;
}
-APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int ofamily,
- int type, apr_pool_t *cont)
+apr_status_t socket_create(apr_socket_t **new, int ofamily,
+ int type, apr_pool_t *cont)
{
int family = ofamily;
@@ -168,8 +168,7 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_shutdown(apr_socket_t *thesocket,
- apr_shutdown_how_e how)
+apr_status_t socket_shutdown(apr_socket_t *thesocket, apr_shutdown_how_e how)
{
int winhow;
@@ -197,13 +196,13 @@
}
}
-APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket)
+apr_status_t socket_close(apr_socket_t *thesocket)
{
apr_pool_cleanup_kill(thesocket->cntxt, thesocket, socket_cleanup);
return socket_cleanup(thesocket);
}
-APR_DECLARE(apr_status_t) apr_bind(apr_socket_t *sock, apr_sockaddr_t *sa)
+apr_status_t socket_bind(apr_socket_t *sock, apr_sockaddr_t *sa)
{
if (bind(sock->sock,
(struct sockaddr *)&sa->sa,
@@ -219,7 +218,7 @@
}
}
-APR_DECLARE(apr_status_t) apr_listen(apr_socket_t *sock, apr_int32_t backlog)
+apr_status_t socket_listen(apr_socket_t *sock, apr_int32_t backlog)
{
if (listen(sock->sock, backlog) == SOCKET_ERROR)
return apr_get_netos_error();
@@ -227,8 +226,7 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_accept(apr_socket_t **new, apr_socket_t *sock,
- apr_pool_t *p)
+apr_status_t socket_accept(apr_socket_t **new, apr_socket_t *sock, apr_pool_t *p)
{
alloc_socket(new, p);
set_socket_vars(*new, sock->local_addr->sa.sin.sin_family, SOCK_STREAM);
@@ -276,7 +274,7 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
+apr_status_t socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
{
apr_status_t rv;
@@ -347,15 +345,13 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key,
+apr_status_t socket_data_get(void **data, const char *key,
apr_socket_t *socket)
{
return apr_pool_userdata_get(data, key, socket->cntxt);
}
-APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *socket, void *data,
- const char *key,
- apr_status_t (*cleanup)(void *))
+apr_status_t socket_data_set(apr_socket_t *socket, void *data, const char *key,
apr_status_t (*cleanup)(void *))
{
return apr_pool_userdata_set(data, key, cleanup, socket->cntxt);
}
@@ -421,4 +417,4 @@
APR_DECLARE_UNSET_INHERIT(socket) {
return;
-}
\ No newline at end of file
+}
Index: srclib/apr/network_io/win32/sockopt.c
===================================================================
RCS file: /home/cvs/apr/network_io/win32/sockopt.c,v
retrieving revision 1.35
diff -u -r1.35 sockopt.c
--- srclib/apr/network_io/win32/sockopt.c 2001/08/09 23:26:18 1.35
+++ srclib/apr/network_io/win32/sockopt.c 2001/11/08 14:33:35
@@ -78,8 +78,8 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_setsocketopt(apr_socket_t *sock,
- apr_int32_t opt, apr_int32_t on)
+apr_status_t socket_setsocketopt(apr_socket_t *sock,
+ apr_int32_t opt, apr_int32_t on)
{
int one;
apr_status_t stat;
@@ -170,8 +170,8 @@
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_getsocketopt(apr_socket_t *sock,
- apr_int32_t opt, apr_int32_t *on)
+apr_status_t socket_getsocketopt(apr_socket_t *sock,
+ apr_int32_t opt, apr_int32_t *on)
{
#ifdef NETWARE
int sol_opt = 0;
@@ -231,13 +231,11 @@
}
-APR_DECLARE(apr_status_t) apr_gethostname(char *buf, int len,
- apr_pool_t *cont)
+apr_status_t socket_gethostname(char *buf, int len,
+ apr_pool_t *cont)
{
if (gethostname(buf, len) == -1)
return apr_get_netos_error();
else
return APR_SUCCESS;
}
-
-
Index: support/ab.c
===================================================================
RCS file: /home/cvs/httpd-2.0/support/ab.c,v
retrieving revision 1.83
diff -u -r1.83 ab.c
--- support/ab.c 2001/10/17 13:42:22 1.83
+++ support/ab.c 2001/11/08 14:33:36
@@ -850,7 +850,7 @@
apr_pool_create(&c->ctx, cntxt);
if ((rv = apr_socket_create(&c->aprsock, destsa->sa.sin.sin_family,
- SOCK_STREAM, c->ctx)) != APR_SUCCESS) {
+ SOCK_STREAM, NULL, c->ctx)) != APR_SUCCESS) {
apr_err("socket", rv);
}
c->start = apr_time_now();
Re: [PATCH] APR Socket IOL
Posted by Bill Stoddard <bi...@wstoddard.com>.
Forget a new file...
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "networkio.h"
#include "apr_network_io.h"
#include "apr_portable.h"
#include "inherit.h"
/*
* This file contains the common entry point, on all OSes, into APR for
* each apr_socket_* call
*/
/* Forward declarations for the native APR socket API. */
apr_status_t socket_create(apr_socket_t **sock, int family, int type,
apr_pool_t *p);
apr_status_t socket_shutdown(apr_socket_t *sock, apr_shutdown_how_e how);
apr_status_t socket_close(apr_socket_t *sock);
apr_status_t socket_bind(apr_socket_t *sock, apr_sockaddr_t *sa);
apr_status_t socket_listen(apr_socket_t *sock, apr_int32_t backlog);
apr_status_t socket_accept(apr_socket_t **new_sock, apr_socket_t *sock, apr_pool_t *p);
apr_status_t socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa);
apr_status_t socket_data_get(void **data, const char *key,
apr_socket_t *sock);
apr_status_t socket_data_set(apr_socket_t *sock, void *data,
const char *key,
apr_status_t (*cleanup)(void*));
apr_status_t socket_send(apr_socket_t *sock, const char *buf, apr_size_t *len);
apr_status_t socket_sendv(apr_socket_t *sock, const struct iovec *vec,
apr_int32_t nvec, apr_size_t *len);
apr_status_t socket_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
apr_int32_t flags, const char *buf,
apr_size_t *len);
apr_status_t socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
apr_int32_t flags, char *buf,
apr_size_t *len);
#if APR_HAS_SENDFILE
apr_status_t 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);
#endif /* APR_HAS_SENDFILE */
apr_status_t socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len);
apr_status_t socket_setsocketopt(apr_socket_t *sock, apr_int32_t opt, apr_int32_t on);
apr_status_t socket_getsocketopt(apr_socket_t *sock, apr_int32_t opt, apr_int32_t *on);
apr_status_t socket_addr_get(apr_sockaddr_t **sa, apr_interface_e which,
apr_socket_t *sock);
apr_status_t socket_poll_socket_add(apr_pollfd_t *aprset, apr_socket_t *sock,
apr_int16_t event);
apr_status_t socket_poll_socket_mask(apr_pollfd_t *aprset, apr_socket_t *sock,
apr_int16_t events);
apr_status_t socket_poll_socket_remove(apr_pollfd_t *aprset,
apr_socket_t *sock);
apr_status_t socket_poll_revents_get(apr_int16_t *event, apr_socket_t *sock,
apr_pollfd_t *aprset);
#if APR_FILES_AS_SOCKETS
apr_status_t socket_from_file(apr_socket_t **sock, apr_file_t *file);
#endif /* APR_FILES_AS_SOCKETS */
#if APR_HAS_SO_ACCEPTFILTER
apr_status_t socket_accept_filter(apr_socket_t *sock, char *name, char *args);
#endif
void socket_set_inherit(apr_socket_t *sock);
void socket_unset_inherit(apr_socket_t *sock);
/*
* APR network API
*/
APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **sock,
int family, int type,
apr_socket_iol_t *iol,
apr_pool_t *p)
{
apr_status_t rv;
if (!iol) {
return socket_create(sock, family, type, p);
}
rv = iol->iol_socket_create(sock, family, type, p);
if (rv == APR_SUCCESS) {
(*sock)->iol = iol;
}
return rv;
}
APR_DECLARE(apr_status_t) apr_shutdown(apr_socket_t *sock,
apr_shutdown_how_e how)
{
if (!sock->iol || !sock->iol->iol_socket_shutdown) {
return socket_shutdown(sock, how);
}
return sock->iol->iol_socket_shutdown(sock, how);
}
APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *sock)
{
if (!sock->iol || !sock->iol->iol_socket_close) {
return socket_close(sock);
}
return sock->iol->iol_socket_close(sock);
}
APR_DECLARE(apr_status_t) apr_bind(apr_socket_t *sock, apr_sockaddr_t *sa)
{
if (!sock->iol || !sock->iol->iol_socket_bind) {
return socket_bind(sock, sa);
}
return sock->iol->iol_socket_bind(sock, sa);
}
APR_DECLARE(apr_status_t) apr_listen(apr_socket_t *sock, apr_int32_t backlog)
{
if (!sock->iol || !sock->iol->iol_socket_listen) {
return socket_listen(sock, backlog);
}
return sock->iol->iol_socket_listen(sock, backlog);
}
APR_DECLARE(apr_status_t) apr_accept(apr_socket_t **new_sock,
apr_socket_t *sock,
apr_pool_t *p)
{
if (!sock->iol || !sock->iol->iol_socket_accept) {
return socket_accept(new_sock, sock, p);
}
return sock->iol->iol_socket_accept(new_sock, sock, p);
}
APR_DECLARE(apr_status_t) apr_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
{
if (!sock->iol || !sock->iol->iol_socket_connect) {
return socket_connect(sock, sa);
}
return sock->iol->iol_socket_connect(sock, sa);
}
APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key,
apr_socket_t *sock)
{
if (!sock->iol || !sock->iol->iol_socket_data_get) {
return socket_data_get(data, key, sock);
}
return sock->iol->iol_socket_data_get(data, key, sock);
}
APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data,
const char *key,
apr_status_t (*cleanup)(void*))
{
if (!sock->iol || !sock->iol->iol_socket_data_set) {
return socket_data_set(sock, data, key, cleanup);
}
return sock->iol->iol_socket_data_set(sock, data, key, cleanup);
}
APR_DECLARE(apr_status_t) apr_send(apr_socket_t *sock, const char *buf,
apr_size_t *len)
{
if (!sock->iol || !sock->iol->iol_socket_send) {
return socket_send(sock, buf, len);
}
return sock->iol->iol_socket_send(sock, buf, len);
}
APR_DECLARE(apr_status_t) apr_sendv(apr_socket_t *sock,
const struct iovec *vec,
apr_int32_t nvec, apr_size_t *len)
{
if (!sock->iol || !sock->iol->iol_socket_sendv) {
return socket_sendv(sock, vec, nvec, len);
}
return sock->iol->iol_socket_sendv(sock, vec, nvec, len);
}
APR_DECLARE(apr_status_t) apr_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
apr_int32_t flags, const char *buf,
apr_size_t *len)
{
if (!sock->iol || !sock->iol->iol_socket_sendto) {
return socket_sendto(sock, where, flags, buf, len);
}
return sock->iol->iol_socket_sendto(sock, where, flags, buf, len);
}
APR_DECLARE(apr_status_t) apr_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
apr_int32_t flags, char *buf,
apr_size_t *len)
{
if (!sock->iol || !sock->iol->iol_socket_recvfrom) {
return socket_recvfrom(from, sock, flags, buf, len);
}
return sock->iol->iol_socket_recvfrom(from, sock, flags, buf, len);
}
#if APR_HAS_SENDFILE
APR_DECLARE(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)
{
if (!sock->iol || !sock->iol->iol_socket_sendfile) {
return socket_sendfile(sock, file, hdtr, offset, len, flags);
}
return sock->iol->iol_socket_sendfile(sock, file, hdtr, offset, len, flags);
}
#endif /* APR_HAS_SENDFILE */
APR_DECLARE(apr_status_t) apr_recv(apr_socket_t *sock,
char *buf, apr_size_t *len)
{
if (!sock->iol || !sock->iol->iol_socket_recv) {
return socket_recv(sock, buf, len);
}
return sock->iol->iol_socket_recv(sock, buf, len);
}
APR_DECLARE(apr_status_t) apr_setsocketopt(apr_socket_t *sock,
apr_int32_t opt, apr_int32_t on)
{
if (!sock->iol || !sock->iol->iol_socket_setsocketopt) {
return socket_setsocketopt(sock, opt, on);
}
return sock->iol->iol_socket_setsocketopt(sock, opt, on);
}
APR_DECLARE(apr_status_t) apr_getsocketopt(apr_socket_t *sock,
apr_int32_t opt, apr_int32_t *on)
{
if (!sock->iol || !sock->iol->iol_socket_getsocketopt) {
return socket_getsocketopt(sock, opt, on);
}
return sock->iol->iol_socket_getsocketopt(sock, opt, on);
}
/* XXX: Do we really need this function to be iol'ized */
APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa,
apr_interface_e which,
apr_socket_t *sock)
{
if (!sock->iol || !sock->iol->iol_socket_addr_get) {
return socket_addr_get(sa, which, sock);
}
return sock->iol->iol_socket_addr_get(sa, which, sock);
}
/* XXX: Do we really need this function to be iol'ized */
APR_DECLARE(apr_status_t) apr_poll_socket_add(apr_pollfd_t *aprset,
apr_socket_t *sock,
apr_int16_t event)
{
if (!sock->iol || !sock->iol->iol_socket_poll_socket_add) {
return socket_poll_socket_add(aprset, sock, event);
}
return sock->iol->iol_socket_poll_socket_add(aprset, sock, event);
}
/* XXX: Do we really need this function to be iol'ized */
APR_DECLARE(apr_status_t) apr_poll_socket_mask(apr_pollfd_t *aprset,
apr_socket_t *sock,
apr_int16_t events)
{
if (!sock->iol || !sock->iol->iol_socket_poll_socket_mask) {
return socket_poll_socket_mask(aprset, sock, events);
}
return sock->iol->iol_socket_poll_socket_mask(aprset, sock, events);
}
/* XXX: Do we really need this function to be iol'ized */
APR_DECLARE(apr_status_t) apr_poll_socket_remove(apr_pollfd_t *aprset,
apr_socket_t *sock)
{
if (!sock->iol || !sock->iol->iol_socket_poll_socket_remove) {
return socket_poll_socket_remove(aprset, sock);
}
return sock->iol->iol_socket_poll_socket_remove(aprset, sock);
}
/* XXX: Do we really need this function to be iol'ized */
APR_DECLARE(apr_status_t) apr_poll_revents_get(apr_int16_t *event,
apr_socket_t *sock,
apr_pollfd_t *aprset)
{
if (!sock->iol || !sock->iol->iol_socket_poll_revents_get) {
return socket_poll_revents_get(event, sock, aprset);
}
return sock->iol->iol_socket_poll_revents_get(event, sock, aprset);
}
#if APR_FILES_AS_SOCKETS
APR_DECLARE(apr_status_t) apr_socket_from_file(apr_socket_t **sock,
apr_file_t *file)
{
if (!sock->iol || !sock->iol->iol_socket_from_file) {
return socket_from_file(sock, file);
}
return sock->iol->iol_socket_from_file(sock, file);
}
#endif /* APR_FILES_AS_SOCKETS */
#if APR_HAS_SO_ACCEPTFILTER
APR_DECLARE(apr_status_t) apr_socket_accept_filter(apr_socket_t *sock, char *name,
char *args)
{
if (!sock->iol || !sock->iol->iol_socket_accept_filter) {
return socket_accept_filter(sock, name, args);
}
return sock->iol->iol_socket_accept_filter(sock, name, args);
}
#endif
Re: [PATCH] APR Socket IOL
Posted by Ryan Bloom <rb...@covalent.net>.
On Friday 09 November 2001 12:38 pm, Bill Stoddard wrote:
> Thank you for a perfect explanation. Now I grok and agree!
>
> The work that needs to be done:
>
> 1. Figure out how to set network io options via the filter API and move all
> these network apr calls that live outside the filter chain into the
> filters.
>
> 2. Add a couple of additional filters, net_in and net_out that live below
> core_in and core_out respectively
>
> 3. move the apr network io calls out of core_in and core_out into net_in
> and net_out
I have a plan for attacking these. I should have a patch in a little while.
My thought is to move the socket out of the conn_rec. This will force
us to do things in the right places.
Ryan
>
> Bill
>
> ----- Original Message -----
> From: "Roy T. Fielding" <fi...@ebuilt.com>
> To: "Bill Stoddard" <bi...@wstoddard.com>
> Cc: "APR Development List" <de...@apr.apache.org>
> Sent: Friday, November 09, 2001 2:39 PM
> Subject: Re: [PATCH] APR Socket IOL
>
> > > I have an socket-like API. I need to issue my_accept(),
> > > my_setsockopt(), my_recv(), my_send(), my_sendfile(), et. al. These
> > > calls are scattered all across httpd. Are you saying I need an accept()
> > > filter, a recv() filter, et. al? Or that there needs to be
>
> a
>
> > > set of generic filter APIs created specific to manipulating network
> > > options? And that
>
> each
>
> > > filter should grok these APIs and pass them down all the way to the
> > > network layer?
> >
> > The filter API is supposed to be an abstract IO layer that is
> > implementation independent. That doesn't mean lowest-common-denominator
> > -- it simply means that all IO calls must go through the filter chain in
> > order to be interpreted properly. Any code that sets IO options without
> > going through that chain is a bug, because the users of filters do not
> > know what exists underneath the filter, and filters themselves do not
> > know what is underneath the next filter down the chain, so attempting to
> > set socket options based on the theory that the bottom of the chain is a
> > socket will be an abstraction violation that will eventually bite someone
> > in the ass.
> >
> > In other words, if the socket calls are spread all over the code, the
> > solution is to find a way to direct those calls through the filter stack
> > so that they can be interpreted by the socket-interface filter, since
> > then you can simply replace the socket-interface filter at run-time with
> > one that uses your special library calls, and the result is no extra
> > overhead for anybody and a cleaner separation between Apache code and
> > third-party code.
> >
> > I don't know if it is possible to do that with the current API, but I
> > do know that the whole idea of filters doesn't work if any abstraction
> > violations are allowed [which is already a problem because metadata is
> > not being passed through the chain].
> >
> > ....Roy
--
______________________________________________________________
Ryan Bloom rbb@apache.org
Covalent Technologies rbb@covalent.net
--------------------------------------------------------------
Re: [PATCH] APR Socket IOL
Posted by Bill Stoddard <bi...@wstoddard.com>.
Thank you for a perfect explanation. Now I grok and agree!
The work that needs to be done:
1. Figure out how to set network io options via the filter API and move all these network
apr calls that live outside the filter chain into the filters.
2. Add a couple of additional filters, net_in and net_out that live below core_in and
core_out respectively
3. move the apr network io calls out of core_in and core_out into net_in and net_out
Bill
----- Original Message -----
From: "Roy T. Fielding" <fi...@ebuilt.com>
To: "Bill Stoddard" <bi...@wstoddard.com>
Cc: "APR Development List" <de...@apr.apache.org>
Sent: Friday, November 09, 2001 2:39 PM
Subject: Re: [PATCH] APR Socket IOL
> > I have an socket-like API. I need to issue my_accept(), my_setsockopt(), my_recv(),
> > my_send(), my_sendfile(), et. al. These calls are scattered all across httpd. Are you
> > saying I need an accept() filter, a recv() filter, et. al? Or that there needs to be
a
> > set of generic filter APIs created specific to manipulating network options? And that
each
> > filter should grok these APIs and pass them down all the way to the network layer?
>
> The filter API is supposed to be an abstract IO layer that is implementation
> independent. That doesn't mean lowest-common-denominator -- it simply means
> that all IO calls must go through the filter chain in order to be interpreted
> properly. Any code that sets IO options without going through that chain
> is a bug, because the users of filters do not know what exists underneath
> the filter, and filters themselves do not know what is underneath the next
> filter down the chain, so attempting to set socket options based on the
> theory that the bottom of the chain is a socket will be an abstraction
> violation that will eventually bite someone in the ass.
>
> In other words, if the socket calls are spread all over the code, the
> solution is to find a way to direct those calls through the filter stack
> so that they can be interpreted by the socket-interface filter, since then
> you can simply replace the socket-interface filter at run-time with one that
> uses your special library calls, and the result is no extra overhead for
> anybody and a cleaner separation between Apache code and third-party code.
>
> I don't know if it is possible to do that with the current API, but I
> do know that the whole idea of filters doesn't work if any abstraction
> violations are allowed [which is already a problem because metadata is
> not being passed through the chain].
>
> ....Roy
>
Re: [PATCH] APR Socket IOL
Posted by "Roy T. Fielding" <fi...@ebuilt.com>.
> I have an socket-like API. I need to issue my_accept(), my_setsockopt(), my_recv(),
> my_send(), my_sendfile(), et. al. These calls are scattered all across httpd. Are you
> saying I need an accept() filter, a recv() filter, et. al? Or that there needs to be a
> set of generic filter APIs created specific to manipulating network options? And that each
> filter should grok these APIs and pass them down all the way to the network layer?
The filter API is supposed to be an abstract IO layer that is implementation
independent. That doesn't mean lowest-common-denominator -- it simply means
that all IO calls must go through the filter chain in order to be interpreted
properly. Any code that sets IO options without going through that chain
is a bug, because the users of filters do not know what exists underneath
the filter, and filters themselves do not know what is underneath the next
filter down the chain, so attempting to set socket options based on the
theory that the bottom of the chain is a socket will be an abstraction
violation that will eventually bite someone in the ass.
In other words, if the socket calls are spread all over the code, the
solution is to find a way to direct those calls through the filter stack
so that they can be interpreted by the socket-interface filter, since then
you can simply replace the socket-interface filter at run-time with one that
uses your special library calls, and the result is no extra overhead for
anybody and a cleaner separation between Apache code and third-party code.
I don't know if it is possible to do that with the current API, but I
do know that the whole idea of filters doesn't work if any abstraction
violations are allowed [which is already a problem because metadata is
not being passed through the chain].
....Roy
Re: [PATCH] APR Socket IOL
Posted by Bill Stoddard <bi...@wstoddard.com>.
> On Thursday 08 November 2001 03:53 pm, Roy T. Fielding wrote:
> > > > What you are suggesting will not work at all. There are apr_socket(and
> > > > related) calls in places other than the core_*_filters. And it is not
> > > > safe to make these calls (which will call BSD socket network io system
> > > > calls) using descriptors from a different network interface.
> > >
> > > Then I would consider the filtering logic broken. If you can't replace
> > > the underlying network types, then we need to move all of the network
> > > calls in the core into new hooks, that can be bypassed if a different
> > > network mechanism is required.
> >
> > Not really. It just means that the network options being set on the
> > sockets directly today should instead be set (in an abstract sense) on the
> > top of the filter chain, which would propagate them down to the filter that
> > is IO-specific. In reality, there are only a couple types of filters that
> > would ever have a legitimate reason to set socket options, and they are
> > very close to the IO-specific filter in the chain.
>
> Yeah, that is another way to do this. Either way, this is the correct way to
> replace the underlying network code.
>
> Ryan
I don't grok what either of you (Roy or Ryan) is saying.
I have an socket-like API. I need to issue my_accept(), my_setsockopt(), my_recv(),
my_send(), my_sendfile(), et. al. These calls are scattered all across httpd. Are you
saying I need an accept() filter, a recv() filter, et. al? Or that there needs to be a
set of generic filter APIs created specific to manipulating network options? And that each
filter should grok these APIs and pass them down all the way to the network layer?
I have to solve this problem one way or the other. I would prefer to do it open source
because the idea seems generally useful.
Bill
Re: [PATCH] APR Socket IOL
Posted by Ryan Bloom <rb...@covalent.net>.
On Thursday 08 November 2001 03:53 pm, Roy T. Fielding wrote:
> > > What you are suggesting will not work at all. There are apr_socket(and
> > > related) calls in places other than the core_*_filters. And it is not
> > > safe to make these calls (which will call BSD socket network io system
> > > calls) using descriptors from a different network interface.
> >
> > Then I would consider the filtering logic broken. If you can't replace
> > the underlying network types, then we need to move all of the network
> > calls in the core into new hooks, that can be bypassed if a different
> > network mechanism is required.
>
> Not really. It just means that the network options being set on the
> sockets directly today should instead be set (in an abstract sense) on the
> top of the filter chain, which would propagate them down to the filter that
> is IO-specific. In reality, there are only a couple types of filters that
> would ever have a legitimate reason to set socket options, and they are
> very close to the IO-specific filter in the chain.
Yeah, that is another way to do this. Either way, this is the correct way to
replace the underlying network code.
Ryan
______________________________________________________________
Ryan Bloom rbb@apache.org
Covalent Technologies rbb@covalent.net
--------------------------------------------------------------
Re: [PATCH] APR Socket IOL
Posted by Bill Stoddard <bi...@wstoddard.com>.
>
>
> > On Thursday 08 November 2001 01:34 pm, Bill Stoddard wrote:
> > >
> > > What you are suggesting will not work at all. There are apr_socket(and
> > > related) calls in places other than the core_*_filters. And it is not safe
> > > to make these calls (which will call BSD socket network io system calls)
> > > using descriptors from a different network interface.
> >
> > Then I would consider the filtering logic broken. If you can't replace the
> > underlying network types, then we need to move all of the network calls in
> > the core into new hooks, that can be bypassed if a different network mechanism
> > is required.
>
> This really sounds to me like you mean to -replace- the apr/network_io/unix
> directory with the appropriate calls for the API.
I only need to use alternate implementations of apr_socket_*() in some cases. And I need
to be able to select which network interface to use at runtime, not compile time.
>
> I can't picture mixing one socket provider with another in a given build of
> the apr. Wouldn't this cause all sorts of problems if a module author called
> a given apr function to create a 'conflicting' socket?
I need to use two different socket providers simultaniously. For example, my kernel cache
which requires the alternate socket API does not support SSL. httpd would use this
alternate socket API to listen on port 80. httpd SSL would use standard socket APIs to
listen on port 443.
And you comment about conflicting sockets is dead on as to why I need the IOL abstraction.
Precisly to prevent httpd from calling the standard socket API using a descriptor from my
own API. With the socket iol, a third party module can just use apr_socket* calls w/o
worrying about how they are implemented under the covers. It just works.
I am really doubtful that filters are the solution here but I am trying to understand :-)
Bill
Re: [PATCH] APR Socket IOL
Posted by "William A. Rowe, Jr." <wr...@covalent.net>.
From: "Ryan Bloom" <rb...@covalent.net>
Sent: Thursday, November 08, 2001 5:01 PM
> On Thursday 08 November 2001 01:34 pm, Bill Stoddard wrote:
> >
> > What you are suggesting will not work at all. There are apr_socket(and
> > related) calls in places other than the core_*_filters. And it is not safe
> > to make these calls (which will call BSD socket network io system calls)
> > using descriptors from a different network interface.
>
> Then I would consider the filtering logic broken. If you can't replace the
> underlying network types, then we need to move all of the network calls in
> the core into new hooks, that can be bypassed if a different network mechanism
> is required.
This really sounds to me like you mean to -replace- the apr/network_io/unix
directory with the appropriate calls for the API.
I can't picture mixing one socket provider with another in a given build of
the apr. Wouldn't this cause all sorts of problems if a module author called
a given apr function to create a 'conflicting' socket?
It seems you need a 'custom' build of apr with the appropriate stubs to this
propritary library - which would superceed all socket-related calls or none.
Is there an application where both the 'native' sockets and your libraries'
sockets would be used in the same app?
Bill
Re: [PATCH] APR Socket IOL
Posted by Ryan Bloom <rb...@covalent.net>.
On Friday 09 November 2001 06:07 am, Bill Stoddard wrote:
>
> > Not really. It just means that the network options being set on the
> > sockets directly today should instead be set (in an abstract sense) on
> > the top of the filter chain, which would propagate them down to the
> > filter that is IO-specific. In reality, there are only a couple types of
> > filters that would ever have a legitimate reason to set socket options,
> > and they are very close to the IO-specific filter in the chain.
>
> Not sure you guys understand exactly why I think I need socket iol, so I'll
> try to explain it in more detail. If there is a better, more extensible way
> to solve my problem, I am all ears but I don;t see it yet.
Bill, I do understand what you are looking for. Remember, I did do a little
bit of work that has involved looking at the kernel cache before. Here is
what I am saying, there are two ways to do this:
1) Make APR a wrapper around a bunch of different socket backends. This
has the same problem as the DB backend issue and the lock backend issue.
Namely, it is going to be next to impossible to do cleanly. It also introduces a
bunch of logic that is really Apache specific. In fact, this isn't even Apache
specific, there are a couple of modules that want this.
2) Use an Apache module to implement this, using filters and hooks.
Option 2 will require investigating all of the places that we make socket calls
in Apache.
Core:
Lingering close
New connection This could probably move to later in the code
get_remote_host
get_server_name
make_sock (only used if ap_listen_open created the socket)
close_listeners_on_exec (only used if ap_listen_open created the socket)
find_default_family (only used in ap_set_listener : Listen directive)
alloc_listener (only used in ap_set_listener : Listen directive)
disable_nagle (only used if ap_listen_open created the socket)
pod_signal (client side)
rfc1413.c (client side)
add_common_vars
check_hostalias
check_serverpath
MPM:
accept
accept error conditions
A more exhaustive analysis might be good too, but the reality is that most of
these calls are grouped into a few very small locations in the code. A lot of
them could move all the way down to the core_output_filter, or possibly to
the very first filter in the stack, which would always correspond to the
lowest filter.
The only really hard one is the accept stuff. That could be done with a simple
hook.
To ensure that the core never calls a regular socket operation on your socket,
you would put your socket in a module's configuration structure.
Ryan
______________________________________________________________
Ryan Bloom rbb@apache.org
Covalent Technologies rbb@covalent.net
--------------------------------------------------------------
Re: [PATCH] APR Socket IOL
Posted by Bill Stoddard <bi...@wstoddard.com>.
>
> > Just to add my (inflation-adjusted) 2 cents worth.
> > I may be way off on this but it sounds like you're attempting to move the complexity
> from your
> > code down into the APR layer.
>
> Well, yea. That is the whole story behind APR. Some folks in the Apache httpd project
> think APR is a bad idea because it introduces excessive complexity. From their
> perspactive, POSIX is a perfectly acceptable API and if an OS doesn't support POSIX then
> Apache shouldn't bother running on that OS :-)
>
> > I know that you can sometimes avoid a huge mess by making a
> > small change in a lower layer of code however I'd question whether modifying a
> general-purpose
> > library for what seems to be a highly specific one off problem is a good idea.
Sometimes
> you
> > just have to bite the bullet and duplicate-munge your code ....
> > G.
>
> Yes, I completely understand and have the same concern. Thought I'd offer up a patch in
> case there was common interest. If not, then I understand and will patch my copy of APR
to
> do what I need.
>
> I am still interested in Roy and Ryan's assertion that this can be solved with filters.
I
> don't see how this problem can be fixed with filters.
>
One other comment... this is not really a 'one off' solution as you imply. socket iol can
be used to work with the secure socket API in many SSL libraries (including OpenSSL, IBM's
GSKIT and MS's secure socket API). Sander Striker had a use for the socket iol in Samba.
So there are a few uses for it other than my specific use.
Bill
Re: [PATCH] APR Socket IOL
Posted by Bill Stoddard <bi...@wstoddard.com>.
> Just to add my (inflation-adjusted) 2 cents worth.
> I may be way off on this but it sounds like you're attempting to move the complexity
from your
> code down into the APR layer.
Well, yea. That is the whole story behind APR. Some folks in the Apache httpd project
think APR is a bad idea because it introduces excessive complexity. From their
perspactive, POSIX is a perfectly acceptable API and if an OS doesn't support POSIX then
Apache shouldn't bother running on that OS :-)
> I know that you can sometimes avoid a huge mess by making a
> small change in a lower layer of code however I'd question whether modifying a
general-purpose
> library for what seems to be a highly specific one off problem is a good idea. Sometimes
you
> just have to bite the bullet and duplicate-munge your code ....
> G.
Yes, I completely understand and have the same concern. Thought I'd offer up a patch in
case there was common interest. If not, then I understand and will patch my copy of APR to
do what I need.
I am still interested in Roy and Ryan's assertion that this can be solved with filters. I
don't see how this problem can be fixed with filters.
Bill
>
> Bill Stoddard wrote:
>
> > > > > What you are suggesting will not work at all. There are apr_socket(and
> > > > > related) calls in places other than the core_*_filters. And it is not safe
> > > > > to make these calls (which will call BSD socket network io system calls)
> > > > > using descriptors from a different network interface.
> > > >
> > > > Then I would consider the filtering logic broken. If you can't replace the
> > > > underlying network types, then we need to move all of the network calls in
> > > > the core into new hooks, that can be bypassed if a different network mechanism
> > > > is required.
> > >
> > > Not really. It just means that the network options being set on the sockets
> > > directly today should instead be set (in an abstract sense) on the top of
> > > the filter chain, which would propagate them down to the filter that is
> > > IO-specific. In reality, there are only a couple types of filters that
> > > would ever have a legitimate reason to set socket options, and they are
> > > very close to the IO-specific filter in the chain.
> > >
> > > ....Roy
> >
> > Not sure you guys understand exactly why I think I need socket iol, so I'll try to
explain
> > it in more detail. If there is a better, more extensible way to solve my problem, I am
all
> > ears but I don;t see it yet.
> >
> > On Windows, I have a kernel resident HTTP GET engine that can serve static content out
of
> > a cache very quickly. The cache is dynamically loaded by httpd as the server runs.
> >
> > httpd communicates with this cache via a custom API. This API consists of a cache
> > management API (put stuff into the cache, take stuff out of the cache, refresh the
cache,
> > etc.), an API to enable starting/stopping/restarting the cache engine, and a socket
like
> > network API for httpd to do io with the cache. It is the network API that is driving
my
> > desire for socket iols in APR.
> >
> > For reasons I don't want to delve into, we decided to implement a socket like API for
> > httpd to do network io with/through the kernel resident cache. This API is for most
> > purposes symantically identical to the BSD socket API -for handling inbound
connections-.
> > It implements open(), close(), accept(), read(), write(), setopt(), etc. (an aside,
the
> > custom socket layer communicates with the Windows TCP/IP stack via the TDI interface
in
> > the Windows kernel. TDI documentation is piss poor at best and we had to reverse
engineer
> > the behaviour of many of the TDI calls which were documented incorrectly. I would
never
> > recommend anyone do TDI programming.)
> >
> > Consider the normal simple case of starting httpd listening on port 80. If the cache
is
> > enabled, the cache engine is started when httpd is started. httpd tells the cache
engine
> > what address/port to listen for requests on (the cache engine actually listens on the
> > port/ip address). httpd uses it's custom socket API to handle requests 'punted' to
httpd
> > from the cache engine (cache misses).
> >
> > The cache engine does not support SSL. So if SSL is also enabled in addition to
standard
> > port 80, httpd needs to listen for port 443 traffic using the standard socket APIs (On
> > windows, we use seperate thread to listen on each port so there is no issue of doing
> > select on the two different style of socket descriptors).
> >
> > Hope this helps explain what I am looking for.
> >
> > Bill
>
>
Re: [PATCH] APR Socket IOL
Posted by Gregory Nicholls <gr...@bellsouth.net>.
Just to add my (inflation-adjusted) 2 cents worth.
I may be way off on this but it sounds like you're attempting to move the complexity from your
code down into the APR layer. I know that you can sometimes avoid a huge mess by making a
small change in a lower layer of code however I'd question whether modifying a general-purpose
library for what seems to be a highly specific one off problem is a good idea. Sometimes you
just have to bite the bullet and duplicate-munge your code ....
G.
Bill Stoddard wrote:
> > > > What you are suggesting will not work at all. There are apr_socket(and
> > > > related) calls in places other than the core_*_filters. And it is not safe
> > > > to make these calls (which will call BSD socket network io system calls)
> > > > using descriptors from a different network interface.
> > >
> > > Then I would consider the filtering logic broken. If you can't replace the
> > > underlying network types, then we need to move all of the network calls in
> > > the core into new hooks, that can be bypassed if a different network mechanism
> > > is required.
> >
> > Not really. It just means that the network options being set on the sockets
> > directly today should instead be set (in an abstract sense) on the top of
> > the filter chain, which would propagate them down to the filter that is
> > IO-specific. In reality, there are only a couple types of filters that
> > would ever have a legitimate reason to set socket options, and they are
> > very close to the IO-specific filter in the chain.
> >
> > ....Roy
>
> Not sure you guys understand exactly why I think I need socket iol, so I'll try to explain
> it in more detail. If there is a better, more extensible way to solve my problem, I am all
> ears but I don;t see it yet.
>
> On Windows, I have a kernel resident HTTP GET engine that can serve static content out of
> a cache very quickly. The cache is dynamically loaded by httpd as the server runs.
>
> httpd communicates with this cache via a custom API. This API consists of a cache
> management API (put stuff into the cache, take stuff out of the cache, refresh the cache,
> etc.), an API to enable starting/stopping/restarting the cache engine, and a socket like
> network API for httpd to do io with the cache. It is the network API that is driving my
> desire for socket iols in APR.
>
> For reasons I don't want to delve into, we decided to implement a socket like API for
> httpd to do network io with/through the kernel resident cache. This API is for most
> purposes symantically identical to the BSD socket API -for handling inbound connections-.
> It implements open(), close(), accept(), read(), write(), setopt(), etc. (an aside, the
> custom socket layer communicates with the Windows TCP/IP stack via the TDI interface in
> the Windows kernel. TDI documentation is piss poor at best and we had to reverse engineer
> the behaviour of many of the TDI calls which were documented incorrectly. I would never
> recommend anyone do TDI programming.)
>
> Consider the normal simple case of starting httpd listening on port 80. If the cache is
> enabled, the cache engine is started when httpd is started. httpd tells the cache engine
> what address/port to listen for requests on (the cache engine actually listens on the
> port/ip address). httpd uses it's custom socket API to handle requests 'punted' to httpd
> from the cache engine (cache misses).
>
> The cache engine does not support SSL. So if SSL is also enabled in addition to standard
> port 80, httpd needs to listen for port 443 traffic using the standard socket APIs (On
> windows, we use seperate thread to listen on each port so there is no issue of doing
> select on the two different style of socket descriptors).
>
> Hope this helps explain what I am looking for.
>
> Bill
Re: [PATCH] APR Socket IOL
Posted by Bill Stoddard <bi...@wstoddard.com>.
> > > What you are suggesting will not work at all. There are apr_socket(and
> > > related) calls in places other than the core_*_filters. And it is not safe
> > > to make these calls (which will call BSD socket network io system calls)
> > > using descriptors from a different network interface.
> >
> > Then I would consider the filtering logic broken. If you can't replace the
> > underlying network types, then we need to move all of the network calls in
> > the core into new hooks, that can be bypassed if a different network mechanism
> > is required.
>
> Not really. It just means that the network options being set on the sockets
> directly today should instead be set (in an abstract sense) on the top of
> the filter chain, which would propagate them down to the filter that is
> IO-specific. In reality, there are only a couple types of filters that
> would ever have a legitimate reason to set socket options, and they are
> very close to the IO-specific filter in the chain.
>
> ....Roy
Not sure you guys understand exactly why I think I need socket iol, so I'll try to explain
it in more detail. If there is a better, more extensible way to solve my problem, I am all
ears but I don;t see it yet.
On Windows, I have a kernel resident HTTP GET engine that can serve static content out of
a cache very quickly. The cache is dynamically loaded by httpd as the server runs.
httpd communicates with this cache via a custom API. This API consists of a cache
management API (put stuff into the cache, take stuff out of the cache, refresh the cache,
etc.), an API to enable starting/stopping/restarting the cache engine, and a socket like
network API for httpd to do io with the cache. It is the network API that is driving my
desire for socket iols in APR.
For reasons I don't want to delve into, we decided to implement a socket like API for
httpd to do network io with/through the kernel resident cache. This API is for most
purposes symantically identical to the BSD socket API -for handling inbound connections-.
It implements open(), close(), accept(), read(), write(), setopt(), etc. (an aside, the
custom socket layer communicates with the Windows TCP/IP stack via the TDI interface in
the Windows kernel. TDI documentation is piss poor at best and we had to reverse engineer
the behaviour of many of the TDI calls which were documented incorrectly. I would never
recommend anyone do TDI programming.)
Consider the normal simple case of starting httpd listening on port 80. If the cache is
enabled, the cache engine is started when httpd is started. httpd tells the cache engine
what address/port to listen for requests on (the cache engine actually listens on the
port/ip address). httpd uses it's custom socket API to handle requests 'punted' to httpd
from the cache engine (cache misses).
The cache engine does not support SSL. So if SSL is also enabled in addition to standard
port 80, httpd needs to listen for port 443 traffic using the standard socket APIs (On
windows, we use seperate thread to listen on each port so there is no issue of doing
select on the two different style of socket descriptors).
Hope this helps explain what I am looking for.
Bill
Re: [PATCH] APR Socket IOL
Posted by "Roy T. Fielding" <fi...@ebuilt.com>.
> > What you are suggesting will not work at all. There are apr_socket(and
> > related) calls in places other than the core_*_filters. And it is not safe
> > to make these calls (which will call BSD socket network io system calls)
> > using descriptors from a different network interface.
>
> Then I would consider the filtering logic broken. If you can't replace the
> underlying network types, then we need to move all of the network calls in
> the core into new hooks, that can be bypassed if a different network mechanism
> is required.
Not really. It just means that the network options being set on the sockets
directly today should instead be set (in an abstract sense) on the top of
the filter chain, which would propagate them down to the filter that is
IO-specific. In reality, there are only a couple types of filters that
would ever have a legitimate reason to set socket options, and they are
very close to the IO-specific filter in the chain.
....Roy
Re: [PATCH] APR Socket IOL
Posted by Ryan Bloom <rb...@covalent.net>.
On Thursday 08 November 2001 01:34 pm, Bill Stoddard wrote:
> > > Sander and I both have similar requirements. Here are mine...
> > >
> > > 1. My SSL library implements socket style secure APIs (eg, secure_read,
> > > secure_write, et. al). These APIs are semantically identical to BSD
> > > socket APIs.
> > >
> > > 2. I have this little kernel accellerator that, on windows, implements
> > > it's own BSD like socket API. It implements calls like afpa_read,
> > > afpa_write, etc. Again, this API is semantically identical to BSD
> > > sockets.
> > >
> > > The socket IOL makes implementing my SSL and AFPA modules significantly
> > > cleaner. Without iol, I am forced to modify the APR code. For every
> > > network i/o call in APR, I need to add code that looks something like
> > > this:
> > >
> > > if (sock->type == AFPA_SOCK) {
> > > code;
> > > afpa_sock_blah()
> > > } else if (sock->type == SSL_SOCK) {
> > > code;
> > > ssl_sock_blah()
> > > }
> > > else
> > > {
> > > bsd_sock_blah()
> > > }
> > >
> > > With the socket IOL, I can isolate all my modules code within my module
> > > and not touch the rest of the server or APR. I think I may need a
> > > couple of additional APIs to push and pop IOL's. For instance, my SSL
> > > code uses BSD accept() (nothing new there). In the pre_connection hook,
> > > I can detect if the server is enabled for SSL and push the appropriate
> > > IOL onto the socket for all subsequent network io calls.
> >
> > All of this can be done with a new output_filter that does the writes.
> > That output filter would replace the core_output_filter. In fact, one of
> > the reasons that filters were designed they way they were, was to allow
> > for this type of thing to work. By creating the socket_IOL, you are just
> > creating a second way to do the same thing.
>
> What you are suggesting will not work at all. There are apr_socket(and
> related) calls in places other than the core_*_filters. And it is not safe
> to make these calls (which will call BSD socket network io system calls)
> using descriptors from a different network interface.
Then I would consider the filtering logic broken. If you can't replace the
underlying network types, then we need to move all of the network calls in
the core into new hooks, that can be bypassed if a different network mechanism
is required.
Ryan
______________________________________________________________
Ryan Bloom rbb@apache.org
Covalent Technologies rbb@covalent.net
--------------------------------------------------------------
Re: [PATCH] APR Socket IOL
Posted by Bill Stoddard <bi...@wstoddard.com>.
> On Thursday 08 November 2001 12:28 pm, Bill Stoddard wrote:
> > > On Thursday 08 November 2001 07:32 am, Bill Stoddard wrote:
> > <snip>
> >
> > > > Comments?
> > >
> > > What is this supposed to be used for? I'm still not sure that this is
> > > necessary.
> >
> > Sander and I both have similar requirements. Here are mine...
> >
> > 1. My SSL library implements socket style secure APIs (eg, secure_read,
> > secure_write, et. al). These APIs are semantically identical to BSD socket
> > APIs.
> >
> > 2. I have this little kernel accellerator that, on windows, implements it's
> > own BSD like socket API. It implements calls like afpa_read, afpa_write,
> > etc. Again, this API is semantically identical to BSD sockets.
> >
> > The socket IOL makes implementing my SSL and AFPA modules significantly
> > cleaner. Without iol, I am forced to modify the APR code. For every network
> > i/o call in APR, I need to add code that looks something like this:
> >
> > if (sock->type == AFPA_SOCK) {
> > code;
> > afpa_sock_blah()
> > } else if (sock->type == SSL_SOCK) {
> > code;
> > ssl_sock_blah()
> > }
> > else
> > {
> > bsd_sock_blah()
> > }
> >
> > With the socket IOL, I can isolate all my modules code within my module and
> > not touch the rest of the server or APR. I think I may need a couple of
> > additional APIs to push and pop IOL's. For instance, my SSL code uses BSD
> > accept() (nothing new there). In the pre_connection hook, I can detect if
> > the server is enabled for SSL and push the appropriate IOL onto the socket
> > for all subsequent network io calls.
>
> All of this can be done with a new output_filter that does the writes. That
> output filter would replace the core_output_filter. In fact, one of the reasons
> that filters were designed they way they were, was to allow for this type of
> thing to work. By creating the socket_IOL, you are just creating a second
> way to do the same thing.
What you are suggesting will not work at all. There are apr_socket(and related) calls in
places other than the core_*_filters. And it is not safe to make these calls (which will
call BSD socket network io system calls) using descriptors from a different network
interface.
Bill
Re: [PATCH] APR Socket IOL
Posted by Ryan Bloom <rb...@covalent.net>.
On Thursday 08 November 2001 12:28 pm, Bill Stoddard wrote:
> > On Thursday 08 November 2001 07:32 am, Bill Stoddard wrote:
> <snip>
>
> > > Comments?
> >
> > What is this supposed to be used for? I'm still not sure that this is
> > necessary.
>
> Sander and I both have similar requirements. Here are mine...
>
> 1. My SSL library implements socket style secure APIs (eg, secure_read,
> secure_write, et. al). These APIs are semantically identical to BSD socket
> APIs.
>
> 2. I have this little kernel accellerator that, on windows, implements it's
> own BSD like socket API. It implements calls like afpa_read, afpa_write,
> etc. Again, this API is semantically identical to BSD sockets.
>
> The socket IOL makes implementing my SSL and AFPA modules significantly
> cleaner. Without iol, I am forced to modify the APR code. For every network
> i/o call in APR, I need to add code that looks something like this:
>
> if (sock->type == AFPA_SOCK) {
> code;
> afpa_sock_blah()
> } else if (sock->type == SSL_SOCK) {
> code;
> ssl_sock_blah()
> }
> else
> {
> bsd_sock_blah()
> }
>
> With the socket IOL, I can isolate all my modules code within my module and
> not touch the rest of the server or APR. I think I may need a couple of
> additional APIs to push and pop IOL's. For instance, my SSL code uses BSD
> accept() (nothing new there). In the pre_connection hook, I can detect if
> the server is enabled for SSL and push the appropriate IOL onto the socket
> for all subsequent network io calls.
All of this can be done with a new output_filter that does the writes. That
output filter would replace the core_output_filter. In fact, one of the reasons
that filters were designed they way they were, was to allow for this type of
thing to work. By creating the socket_IOL, you are just creating a second
way to do the same thing.
The obvious argument for not using a separate filter is that it requires a lot
of logic to be duplicated. I would argue that isn't true. Most of the
core_output_filter is doing stuff that doesn't make sense with AFPA or the
SSL library, unless those libraries replicate sendfile.
Ryan
______________________________________________________________
Ryan Bloom rbb@apache.org
Covalent Technologies rbb@covalent.net
--------------------------------------------------------------
Re: [PATCH] APR Socket IOL
Posted by Bill Stoddard <bi...@wstoddard.com>.
> On Thursday 08 November 2001 07:32 am, Bill Stoddard wrote:
> > This patch is a first rough implementation of a socket iol in APR (from
> > discussions with Sander Striker a few months back).
> >
> > Public API Changes:
> > No new APIs were created.
> > apr_socket_create() has an extra parameter, a pointer to an
> > apr_socket_iol_t.
> >
> > New Public Structures:
> > apr_socket_iol_t - contains pointers to callback functions.
> >
> > Usage:
> > If you do not want to redirect socket calls and just use existing APR
> > calls, use apr_socket_create() thusly:
> > apr_socket_create(&new_sock, APR_INET, SOCKSTREAM, NULL, r->pool);
> >
> >
<snip>
> > Comments?
>
> What is this supposed to be used for? I'm still not sure that this is necessary.
>
Sander and I both have similar requirements. Here are mine...
1. My SSL library implements socket style secure APIs (eg, secure_read, secure_write, et.
al). These APIs are semantically identical to BSD socket APIs.
2. I have this little kernel accellerator that, on windows, implements it's own BSD like
socket API. It implements calls like afpa_read, afpa_write, etc. Again, this API is
semantically identical to BSD sockets.
The socket IOL makes implementing my SSL and AFPA modules significantly cleaner. Without
iol, I am forced to modify the APR code. For every network i/o call in APR, I need to add
code that looks something like this:
if (sock->type == AFPA_SOCK) {
code;
afpa_sock_blah()
} else if (sock->type == SSL_SOCK) {
code;
ssl_sock_blah()
}
else
{
bsd_sock_blah()
}
With the socket IOL, I can isolate all my modules code within my module and not touch the
rest of the server or APR. I think I may need a couple of additional APIs to push and pop
IOL's. For instance, my SSL code uses BSD accept() (nothing new there). In the
pre_connection hook, I can detect if the server is enabled for SSL and push the
appropriate IOL onto the socket for all subsequent network io calls.
Bill
Re: [PATCH] APR Socket IOL
Posted by Ryan Bloom <rb...@covalent.net>.
On Thursday 08 November 2001 07:32 am, Bill Stoddard wrote:
> This patch is a first rough implementation of a socket iol in APR (from
> discussions with Sander Striker a few months back).
>
> Public API Changes:
> No new APIs were created.
> apr_socket_create() has an extra parameter, a pointer to an
> apr_socket_iol_t.
>
> New Public Structures:
> apr_socket_iol_t - contains pointers to callback functions.
>
> Usage:
> If you do not want to redirect socket calls and just use existing APR
> calls, use apr_socket_create() thusly:
> apr_socket_create(&new_sock, APR_INET, SOCKSTREAM, NULL, r->pool);
>
>
> If you want to redirect socket calls:
>
> /* Set up apr_socket_iol_t with pointers to specific calls you
> * want to redirect
> */
> apr_socket_iol_t *iol;
> iol = apr_pcalloc(r->pool, sizeof(*iol));
> iol->iol_socket_shutdown = pointer_to_your_shutdown_function;
> iol->iol_socket_read = pointer_to_your_read_function;
> iol->iol_socket_write = pointer_to_your_write_function;
> ...
> ...
> apr_socket_create(&new_sock, APR_INET, SOCKSTREAM, iol, r->pool);
>
> Comments:
> This patch implements a single cross platform entry point for all the
> apr_socket_* calls (see network_io/unix/aprsocketapi.c). Most of the code
> in this patch is accounting for this.
>
> I have tested this on Windows. I started modifying code in the Unix branch
> but it is surely is broken.Haven't made any effort on the other network_io
> OS specific branches.
>
> Comments?
What is this supposed to be used for? I'm still not sure that this is necessary.
Ryan
______________________________________________________________
Ryan Bloom rbb@apache.org
Covalent Technologies rbb@covalent.net
--------------------------------------------------------------
Re: [PATCH] APR Socket IOL
Posted by Ryan Bloom <rb...@covalent.net>.
On Thursday 08 November 2001 10:02 am, Bill Stoddard wrote:
> > On Thu, Nov 08, 2001 at 10:32:45AM -0500, Bill Stoddard wrote:
> > > This patch is a first rough implementation of a socket iol in APR (from
> > > discussions
>
> with
>
> > > Sander Striker a few months back).
> > >
> > > Public API Changes:
> > > No new APIs were created.
> > > apr_socket_create() has an extra parameter, a pointer to an
> > > apr_socket_iol_t.
> > >
> > > New Public Structures:
> > > apr_socket_iol_t - contains pointers to callback functions.
> > >
> > > Usage:
> > > If you do not want to redirect socket calls and just use existing APR
> > > calls, use apr_socket_create() thusly:
> > > apr_socket_create(&new_sock, APR_INET, SOCKSTREAM, NULL, r->pool);
> >
> > I thought we were trying to move away from function pointers because
> > people thought they were slow. Could/should we create a parallel API
> > for this instead? -- justin
>
> If we created a parallel API, the all of the HTTP Server (for example)
> apr_socket calls would have to be migrated to this new API; seems rather
> pointless. Adding a lot of complexity to the API just to avoid one function
> call.
>
> Yep, adding another function call/level of indirection chews a bit of CPU
> but it is not that big a deal overall. And in the common case, we will
> -not- be making socket calls via function pointers. In the common case, we
> just make a direct function call. Only when we want to redirect the
> function calls will we use the function pointers.
Why would HTTP use this at all? With filters, this concept isn't necessary
any more.
Ryan
______________________________________________________________
Ryan Bloom rbb@apache.org
Covalent Technologies rbb@covalent.net
--------------------------------------------------------------
Re: [PATCH] APR Socket IOL
Posted by Bill Stoddard <bi...@wstoddard.com>.
> On Thu, Nov 08, 2001 at 10:32:45AM -0500, Bill Stoddard wrote:
> > This patch is a first rough implementation of a socket iol in APR (from discussions
with
> > Sander Striker a few months back).
> >
> > Public API Changes:
> > No new APIs were created.
> > apr_socket_create() has an extra parameter, a pointer to an apr_socket_iol_t.
> >
> > New Public Structures:
> > apr_socket_iol_t - contains pointers to callback functions.
> >
> > Usage:
> > If you do not want to redirect socket calls and just use existing APR calls, use
> > apr_socket_create() thusly:
> > apr_socket_create(&new_sock, APR_INET, SOCKSTREAM, NULL, r->pool);
>
> I thought we were trying to move away from function pointers because
> people thought they were slow. Could/should we create a parallel API
> for this instead? -- justin
>
If we created a parallel API, the all of the HTTP Server (for example) apr_socket calls
would have to be migrated to this new API; seems rather pointless. Adding a lot of
complexity to the API just to avoid one function call.
Yep, adding another function call/level of indirection chews a bit of CPU but it is not
that big a deal overall. And in the common case, we will -not- be making socket calls via
function pointers. In the common case, we just make a direct function call. Only when we
want to redirect the function calls will we use the function pointers.
Bill
Re: [PATCH] APR Socket IOL
Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Thu, Nov 08, 2001 at 10:32:45AM -0500, Bill Stoddard wrote:
> This patch is a first rough implementation of a socket iol in APR (from discussions with
> Sander Striker a few months back).
>
> Public API Changes:
> No new APIs were created.
> apr_socket_create() has an extra parameter, a pointer to an apr_socket_iol_t.
>
> New Public Structures:
> apr_socket_iol_t - contains pointers to callback functions.
>
> Usage:
> If you do not want to redirect socket calls and just use existing APR calls, use
> apr_socket_create() thusly:
> apr_socket_create(&new_sock, APR_INET, SOCKSTREAM, NULL, r->pool);
I thought we were trying to move away from function pointers because
people thought they were slow. Could/should we create a parallel API
for this instead? -- justin