Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 51877 invoked from network); 11 Aug 2004 22:32:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 11 Aug 2004 22:32:25 -0000 Received: (qmail 56144 invoked by uid 500); 11 Aug 2004 22:32:24 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 55997 invoked by uid 500); 11 Aug 2004 22:32:23 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 55984 invoked by uid 500); 11 Aug 2004 22:32:23 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Received: (qmail 55979 invoked by uid 99); 11 Aug 2004 22:32:23 -0000 X-ASF-Spam-Status: No, hits=-2.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Wed, 11 Aug 2004 15:32:23 -0700 Received: (qmail 51858 invoked by uid 1134); 11 Aug 2004 22:32:22 -0000 Date: 11 Aug 2004 22:32:22 -0000 Message-ID: <20040811223222.51857.qmail@minotaur.apache.org> From: wrowe@apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/modules/proxy proxy_util.c X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N wrowe 2004/08/11 15:32:22 Modified: modules/proxy proxy_util.c Log: Change the way the prefork connection is created. Use the same constructor as for theaded mpm's. Added API's for destroying and closing connections Submitted by: mturk Revision Changes Path 1.121 +48 -14 httpd-2.0/modules/proxy/proxy_util.c Index: proxy_util.c =================================================================== RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_util.c,v retrieving revision 1.120 retrieving revision 1.121 diff -u -r1.120 -r1.121 --- proxy_util.c 11 Aug 2004 22:30:06 -0000 1.120 +++ proxy_util.c 11 Aug 2004 22:32:22 -0000 1.121 @@ -1358,12 +1358,30 @@ server_rec *s = (server_rec *)params; apr_pool_destroy(conn->pool); - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, - "proxy: socket is destructed"); + if (s != NULL) + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, + "proxy: socket is destructed"); return APR_SUCCESS; } +/* Destroy the connection */ +PROXY_DECLARE(apr_status_t) ap_proxy_destroy_connection(proxy_conn_rec *conn) +{ + return connection_destructor(conn, NULL, NULL); +} + +/* Destroy the connection */ +PROXY_DECLARE(apr_status_t) ap_proxy_close_connection(proxy_conn_rec *conn) +{ + apr_status_t rv = APR_EOF; + /* Close the socket */ + if (conn->sock) + rv = apr_socket_close(conn->sock); + conn->sock = NULL; + return rv; +} + /* low level connection acquire/release functions * they are hiding apr_reslist for nothreaded or prefork servers. */ @@ -1378,6 +1396,7 @@ #endif { *conn = worker->cp->conn; + worker->cp->conn = NULL; rv = APR_SUCCESS; } return rv; @@ -1390,7 +1409,11 @@ if (worker->hmax) { rv = apr_reslist_release(worker->cp->res, (void *)conn); } + else #endif + { + worker->cp->conn = conn; + } return rv; } @@ -1414,18 +1437,8 @@ else #endif { - worker->cp->conn = apr_pcalloc(worker->cp->pool, sizeof(proxy_conn_rec)); - /* register the pool cleanup. - * The cleanup is registered on conn_pool pool, so that - * the same mechanism (apr_pool_cleanup) can be used - * for both nonthreaded and threaded servers when closing - * the entire worker. - */ - apr_pool_cleanup_register(worker->cp->pool, (void *)worker->cp->conn, - proxy_conn_cleanup, apr_pool_cleanup_null); - - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, - "proxy: socket is created"); + + connection_constructor((void **)&(worker->cp->conn), s, worker->cp->pool); rv = APR_SUCCESS; } return rv; @@ -1514,4 +1527,25 @@ "Connect to remote machine blocked"); } return OK; +} + +static int is_socket_connected(apr_socket_t *sock) + +{ + apr_size_t buffer_len = 1; + char test_buffer[1]; + apr_status_t socket_status; + apr_interval_time_t current_timeout; + + /* save timeout */ + apr_socket_timeout_get(sock, ¤t_timeout); + /* set no timeout */ + apr_socket_timeout_set(sock, 0); + socket_status = apr_socket_recv(sock, test_buffer, &buffer_len); + /* put back old timeout */ + apr_socket_timeout_set(sock, current_timeout); + if (APR_STATUS_IS_EOF(socket_status)) + return 0; + else + return 1; }