bjh 99/10/24 06:08:31
Modified: src/lib/apr/include apr_network_io.h src/lib/apr/network_io/beos sockets.c src/lib/apr/network_io/os2 sockets.c src/lib/apr/network_io/unix sockets.c src/lib/apr/network_io/win32 sockets.c src/lib/apr/test server.c src/modules/mpm/dexter dexter.c src/modules/mpm/mpmt_beos mpmt_beos.c src/modules/mpm/mpmt_pthread mpmt_pthread.c src/modules/mpm/prefork prefork.c src/modules/mpm/spmt_os2 spmt_os2.c Log: Add a context parameter to ap_accept() for the connection socket to be allocated from. This is needed because the lifetime of a connection is ususally much shorter than that of the listen socket. Only tested on OS/2. Revision Changes Path 1.13 +1 -1 apache-2.0/src/lib/apr/include/apr_network_io.h Index: apr_network_io.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_network_io.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- apr_network_io.h 1999/10/24 05:59:13 1.12 +++ apr_network_io.h 1999/10/24 13:08:24 1.13 @@ -114,7 +114,7 @@ ap_status_t ap_bind(ap_socket_t *); ap_status_t ap_listen(ap_socket_t *, ap_int32_t); -ap_status_t ap_accept(ap_socket_t **, const ap_socket_t *); +ap_status_t ap_accept(ap_socket_t **, const ap_socket_t *, ap_context_t *); ap_status_t ap_connect(ap_socket_t *, char *); ap_status_t ap_get_remote_hostname(char **, ap_socket_t *); 1.10 +3 -2 apache-2.0/src/lib/apr/network_io/beos/sockets.c Index: sockets.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/beos/sockets.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- sockets.c 1999/10/24 12:27:33 1.9 +++ sockets.c 1999/10/24 13:08:24 1.10 @@ -140,11 +140,12 @@ return APR_SUCCESS; } -ap_status_t ap_accept(struct socket_t **new, const struct socket_t *sock) +ap_status_t ap_accept(struct socket_t **new, const struct socket_t *sock, struct context_t *connection_context) { - (*new) = (struct socket_t *)ap_palloc(sock->cntxt, + (*new) = (struct socket_t *)ap_palloc(connection_context, sizeof(ap_socket_t)); + (*new)->cntxt = connection_context; (*new)->cntxt = sock->cntxt; (*new)->local_addr = (struct sockaddr_in *)ap_palloc((*new)->cntxt, sizeof(struct sockaddr_in)); 1.6 +3 -3 apache-2.0/src/lib/apr/network_io/os2/sockets.c Index: sockets.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/os2/sockets.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- sockets.c 1999/10/24 05:59:14 1.5 +++ sockets.c 1999/10/24 13:08:25 1.6 @@ -147,12 +147,12 @@ return APR_SUCCESS; } -ap_status_t ap_accept(struct socket_t **new, const struct socket_t *sock) +ap_status_t ap_accept(struct socket_t **new, const struct socket_t *sock, struct context_t *connection_context) { - (*new) = (struct socket_t *)ap_palloc(sock->cntxt, + (*new) = (struct socket_t *)ap_palloc(connection_context, sizeof(struct socket_t)); - (*new)->cntxt = sock->cntxt; + (*new)->cntxt = connection_context; (*new)->remote_addr = (struct sockaddr_in *)ap_palloc((*new)->cntxt, sizeof(struct sockaddr_in)); (*new)->local_addr = sock->local_addr; 1.20 +7 -6 apache-2.0/src/lib/apr/network_io/unix/sockets.c Index: sockets.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sockets.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- sockets.c 1999/10/24 05:59:15 1.19 +++ sockets.c 1999/10/24 13:08:25 1.20 @@ -187,19 +187,20 @@ } /* ***APRDOC******************************************************** - * ap_status_t ap_accept(ap_socket_t **, ap_socket_t *) + * ap_status_t ap_accept(ap_socket_t **, ap_socket_t *, ap_context_t *connection_context) * Accept a new connection request - * arg 1) The socket we are listening on - * arg 2) A copy of the socket that is connected to the socket that + * arg 1) A copy of the socket that is connected to the socket that * made the connection request. This is the socket which should * be used for all future communication. + * arg 2) The socket we are listening on. + * arg 3) The context for the new socket. */ -ap_status_t ap_accept(struct socket_t **new, const struct socket_t *sock) +ap_status_t ap_accept(struct socket_t **new, const struct socket_t *sock, struct context_t *connection_context) { - (*new) = (struct socket_t *)ap_palloc(sock->cntxt, + (*new) = (struct socket_t *)ap_palloc(connection_context, sizeof(struct socket_t)); - (*new)->cntxt = sock->cntxt; + (*new)->cntxt = connection_context; (*new)->local_addr = (struct sockaddr_in *)ap_palloc((*new)->cntxt, sizeof(struct sockaddr_in)); (*new)->remote_addr = (struct sockaddr_in *)ap_palloc((*new)->cntxt, 1.11 +3 -3 apache-2.0/src/lib/apr/network_io/win32/sockets.c Index: sockets.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/win32/sockets.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- sockets.c 1999/10/15 14:20:15 1.10 +++ sockets.c 1999/10/24 13:08:26 1.11 @@ -186,12 +186,12 @@ return APR_SUCCESS; } -ap_status_t ap_accept(struct socket_t **new, const struct socket_t *sock) +ap_status_t ap_accept(struct socket_t **new, const struct socket_t *sock, struct context_t *connection_context) { - (*new) = (struct socket_t *)ap_palloc(sock->cntxt, + (*new) = (struct socket_t *)ap_palloc(connection_context, sizeof(struct socket_t)); - (*new)->cntxt = sock->cntxt; + (*new)->cntxt = connection_context; (*new)->addr = (struct sockaddr_in *)ap_palloc((*new)->cntxt, sizeof(struct sockaddr_in)); (*new)->addr_len = sizeof(struct sockaddr_in); 1.7 +1 -1 apache-2.0/src/lib/apr/test/server.c Index: server.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/test/server.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- server.c 1999/10/24 05:59:17 1.6 +++ server.c 1999/10/24 13:08:26 1.7 @@ -138,7 +138,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tServer: Accepting a connection......."); - if (ap_accept(&sock2, sock) != APR_SUCCESS) { + if (ap_accept(&sock2, sock, context) != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Could not accept connection.\n"); exit(-1); 1.46 +1 -1 apache-2.0/src/modules/mpm/dexter/dexter.c Index: dexter.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/mpm/dexter/dexter.c,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- dexter.c 1999/10/20 19:07:49 1.45 +++ dexter.c 1999/10/24 13:08:27 1.46 @@ -934,7 +934,7 @@ } got_fd: if (!workers_may_exit) { - ap_accept(&csd, sd); + ap_accept(&csd, sd, ptrans); SAFE_ACCEPT(accept_mutex_off(0)); SAFE_ACCEPT(intra_mutex_off(0)); pthread_mutex_lock(&idle_thread_count_mutex); 1.5 +2 -5 apache-2.0/src/modules/mpm/mpmt_beos/mpmt_beos.c Index: mpmt_beos.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/mpm/mpmt_beos/mpmt_beos.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- mpmt_beos.c 1999/10/22 11:28:33 1.4 +++ mpmt_beos.c 1999/10/24 13:08:28 1.5 @@ -673,10 +673,7 @@ conn_io = ap_bcreate(p, B_RDWR); ap_bpush_iol(conn_io, iol); - current_conn = ap_new_connection(p, server_conf, conn_io, - (const struct sockaddr_in *) sa_client, - (const struct sockaddr_in *) &sa_server, - conn_id); + current_conn = ap_new_connection(p, server_conf, conn_io, csd, conn_id); ap_process_connection(current_conn); } @@ -761,7 +758,7 @@ } got_fd: if (!workers_may_exit) { - ap_accept(&csd, sd); + ap_accept(&csd, sd, ptrans); SAFE_ACCEPT(accept_mutex_off(0)); SAFE_ACCEPT(intra_mutex_off(0)); } 1.39 +2 -5 apache-2.0/src/modules/mpm/mpmt_pthread/mpmt_pthread.c Index: mpmt_pthread.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/mpm/mpmt_pthread/mpmt_pthread.c,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- mpmt_pthread.c 1999/10/20 12:50:02 1.38 +++ mpmt_pthread.c 1999/10/24 13:08:28 1.39 @@ -763,10 +763,7 @@ conn_io = ap_bcreate(p, B_RDWR); ap_bpush_iol(conn_io, iol); - current_conn = ap_new_connection(p, server_conf, conn_io, - (const struct sockaddr_in *) sa_client, - (const struct sockaddr_in *) &sa_server, - conn_id); + current_conn = ap_new_apr_connection(p, server_conf, conn_io, csd, conn_id); ap_process_connection(current_conn); } @@ -885,7 +882,7 @@ } got_fd: if (!workers_may_exit) { - ap_accept(&csd, sd); + ap_accept(&csd, sd, ptrans); SAFE_ACCEPT(accept_mutex_off(0)); SAFE_ACCEPT(intra_mutex_off(0)); } 1.49 +1 -1 apache-2.0/src/modules/mpm/prefork/prefork.c Index: prefork.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/mpm/prefork/prefork.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- prefork.c 1999/10/24 07:43:45 1.48 +++ prefork.c 1999/10/24 13:08:29 1.49 @@ -2077,7 +2077,7 @@ clean_child_exit(0); } clen = sizeof(sa_client); - stat = ap_accept(&csd, sd); + stat = ap_accept(&csd, sd, ptrans); if (stat == APR_SUCCESS || stat != APR_EINTR) break; } 1.18 +1 -1 apache-2.0/src/modules/mpm/spmt_os2/spmt_os2.c Index: spmt_os2.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/mpm/spmt_os2/spmt_os2.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- spmt_os2.c 1999/10/24 05:59:22 1.17 +++ spmt_os2.c 1999/10/24 13:08:30 1.18 @@ -1046,7 +1046,7 @@ /* we didn't get a socket, and we were told to die */ clean_child_exit(0); } - rv = ap_accept(&csd, sd); + rv = ap_accept(&csd, sd, ptrans); if (rv != APR_EINTR) break; }