Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 57172 invoked from network); 11 Aug 2004 22:44:41 -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:44:41 -0000 Received: (qmail 71658 invoked by uid 500); 11 Aug 2004 22:44:40 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 71618 invoked by uid 500); 11 Aug 2004 22:44:40 -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 71594 invoked by uid 500); 11 Aug 2004 22:44:39 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Received: (qmail 71591 invoked by uid 99); 11 Aug 2004 22:44:39 -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:44:39 -0700 Received: (qmail 57121 invoked by uid 1134); 11 Aug 2004 22:44:38 -0000 Date: 11 Aug 2004 22:44:38 -0000 Message-ID: <20040811224438.57120.qmail@minotaur.apache.org> From: wrowe@apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/modules/proxy proxy_http.c 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:44:38 Modified: modules/proxy proxy_http.c proxy_util.c Log: Fix the assertion bug for reslist caused by returning the same connection back to the pool twice. Submitted by: mturk Revision Changes Path 1.191 +8 -13 httpd-2.0/modules/proxy/proxy_http.c Index: proxy_http.c =================================================================== RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_http.c,v retrieving revision 1.190 retrieving revision 1.191 diff -u -r1.190 -r1.191 --- proxy_http.c 11 Aug 2004 22:43:44 -0000 1.190 +++ proxy_http.c 11 Aug 2004 22:44:38 -0000 1.191 @@ -796,7 +796,8 @@ } if (len <= 0) { apr_socket_close(backend->sock); - backend->connection = NULL; + backend->sock = NULL; +// backend->connection = NULL; ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "proxy: error reading status line from remote " "server %s", backend->hostname); @@ -819,7 +820,8 @@ */ else if ((buffer[5] != '1') || (len >= sizeof(buffer)-1)) { apr_socket_close(backend->sock); - backend->connection = NULL; +// backend->connection = NULL; + backend->sock = NULL; return ap_proxyerror(r, HTTP_BAD_GATEWAY, apr_pstrcat(p, "Corrupt status line returned by remote " "server: ", buffer, NULL)); @@ -1029,7 +1031,7 @@ * backend server from hanging around waiting * for a slow client to eat these bytes */ - ap_proxy_http_cleanup(NULL, r, backend); + backend->close = 1; /* signal that we must leave */ finish = TRUE; } @@ -1092,18 +1094,11 @@ /* if the connection is < HTTP/1.1, or Connection: close, * we close the socket, otherwise we leave it open for KeepAlive support */ - if (backend->close) { + if (backend->close || (r->proto_num < HTTP_VERSION(1,1))) { backend->close_on_recycle = 1; - ap_set_module_config(r->connection, &proxy_http_module, backend); + ap_set_module_config(r->connection->conn_config, &proxy_http_module, NULL); ap_proxy_release_connection(scheme, backend, r->server); } - else if(r->proto_num < HTTP_VERSION(1,1)) { - if (backend->sock) { - apr_socket_close(backend->sock); - backend->sock = NULL; - backend->connection = NULL; - } - } return OK; } @@ -1231,7 +1226,7 @@ /* Step Five: Receive the Response */ status = ap_proxy_http_process_response(p, r, backend, backend->connection, conf, server_portstr); - if ( status != OK ) { + if (status != OK) { /* clean up even if there is an error */ ap_proxy_http_cleanup(scheme, r, backend); return status; 1.127 +22 -39 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.126 retrieving revision 1.127 diff -u -r1.126 -r1.127 --- proxy_util.c 11 Aug 2004 22:41:02 -0000 1.126 +++ proxy_util.c 11 Aug 2004 22:44:38 -0000 1.127 @@ -1319,14 +1319,24 @@ static apr_status_t connection_cleanup(void *theconn) { proxy_conn_rec *conn = (proxy_conn_rec *)theconn; + proxy_worker *worker = conn->worker; + /* deterimine if the connection need to be closed */ if (conn->close_on_recycle) { if (conn->sock) apr_socket_close(conn->sock); conn->sock = NULL; } - conn->connection = NULL; - ap_proxy_release_connection(NULL, conn, NULL); +#if APR_HAS_THREADS + if (worker->hmax && worker->cp->res) { + apr_reslist_release(worker->cp->res, (void *)conn); + } + else +#endif + { + worker->cp->conn = conn; + } + /* Allways return the SUCCESS */ return APR_SUCCESS; } @@ -1486,39 +1496,12 @@ server_rec *s) { apr_status_t rv = APR_SUCCESS; - proxy_worker *worker = conn->worker; - if (!worker) { - /* something bad happened. Obviously bug. - * for now make a core dump. - */ - } - - /* Need to close the connection */ - if (conn->sock && conn->close) { - apr_socket_close(conn->sock); - conn->sock = NULL; - } - conn->close = 0; /* If there is a connection kill it's cleanup */ if (conn->connection) apr_pool_cleanup_kill(conn->connection->pool, conn, connection_cleanup); - -#if APR_HAS_THREADS - if (worker->hmax && worker->cp->res) { - rv = apr_reslist_release(worker->cp->res, (void *)conn); - } - else -#endif - { - worker->cp->conn = conn; - } - if (rv != APR_SUCCESS && proxy_function) { - ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, - "proxy: %s: failed to acquire connection for (%s)", - proxy_function, conn->hostname); - return DECLINED; - } + connection_cleanup(conn); + conn->connection = NULL; return OK; } @@ -1652,7 +1635,8 @@ while (backend_addr && !connected) { if ((rv = apr_socket_create(&newsock, backend_addr->family, - SOCK_STREAM, 0, conn->pool)) != APR_SUCCESS) { + SOCK_STREAM, APR_PROTO_TCP, + conn->pool)) != APR_SUCCESS) { loglevel = backend_addr->next ? APLOG_DEBUG : APLOG_ERR; ap_log_error(APLOG_MARK, loglevel, rv, s, "proxy: %s: error creating fam %d socket for target %s", @@ -1748,6 +1732,12 @@ conn->sock = NULL; return HTTP_INTERNAL_SERVER_ERROR; } + /* register the connection cleanup to client connection + * so that the connection can be closed or reused + */ + apr_pool_cleanup_register(c->pool, (void *)conn, + connection_cleanup, + apr_pool_cleanup_null); /* For ssl connection to backend */ if (conn->is_ssl) { @@ -1770,13 +1760,6 @@ /* set up the connection filters */ ap_run_pre_connection(conn->connection, conn->sock); - - /* register the connection cleanup to client connection - * so that the connection can be closed or reused - */ - apr_pool_cleanup_register(conn->connection->pool, (void *)conn, - connection_cleanup, - apr_pool_cleanup_null); return OK; }