Return-Path: Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 66058 invoked by uid 500); 1 Aug 2003 10:41:47 -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 66034 invoked by uid 500); 1 Aug 2003 10:41:47 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Date: 1 Aug 2003 10:41:47 -0000 Message-ID: <20030801104147.29335.qmail@minotaur.apache.org> From: trawick@apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/support ab.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N trawick 2003/08/01 03:41:47 Modified: support ab.c Log: distinguish between these two states: . just issued connect(), polling for writability to find out when connect() completed . already connected, waiting for data from the server so polling for readability by only polling for writability during the first state, we avoid some logic in test() which inappropriately writes multiple requests to the server btw, the most basic SSL test segfaulted before and after this commit Revision Changes Path 1.130 +39 -10 httpd-2.0/support/ab.c Index: ab.c =================================================================== RCS file: /home/cvs/httpd-2.0/support/ab.c,v retrieving revision 1.129 retrieving revision 1.130 diff -u -r1.129 -r1.130 --- ab.c 1 Aug 2003 08:57:43 -0000 1.129 +++ ab.c 1 Aug 2003 10:41:46 -0000 1.130 @@ -239,8 +239,11 @@ /* good old state hostname */ #define STATE_UNCONNECTED 0 -#define STATE_CONNECTING 1 -#define STATE_READ 2 +#define STATE_CONNECTING 1 /* TCP connect initiated, but we don't + * know if it worked yet + */ +#define STATE_CONNECTED 2 /* we know TCP connect completed */ +#define STATE_READ 3 #define CBUFFSIZE (2048) @@ -680,7 +683,7 @@ case SSL_ERROR_WANT_CONNECT: BIO_printf(bio_err, "Waiting .. sleep(1)\n"); apr_sleep(apr_time_from_sec(1)); - c->state = STATE_CONNECTING; + c->state = STATE_CONNECTED; c->rwrite = 0; break; case SSL_ERROR_ZERO_RETURN: @@ -1268,7 +1271,7 @@ c->state = STATE_CONNECTING; c->rwrite = 0; new_pollfd.desc_type = APR_POLL_SOCKET; - new_pollfd.reqevents = APR_POLLOUT | APR_POLLIN; + new_pollfd.reqevents = APR_POLLOUT; new_pollfd.desc.s = c->aprsock; new_pollfd.client_data = c; apr_pollset_add(readbits, &new_pollfd); @@ -1293,6 +1296,7 @@ } /* connected first time */ + c->state = STATE_CONNECTED; started++; write_request(c); } @@ -1751,8 +1755,34 @@ start_connect(c); continue; } - if (rv & APR_POLLOUT) - write_request(c); + if (rv & APR_POLLOUT) { + if (c->state == STATE_CONNECTING) { + apr_pollfd_t remove_pollfd; + rv = apr_connect(c->aprsock, destsa); + remove_pollfd.desc_type = APR_POLL_SOCKET; + remove_pollfd.desc.s = c->aprsock; + apr_pollset_remove(readbits, &remove_pollfd); + if (rv != APR_SUCCESS) { + apr_socket_close(c->aprsock); + err_conn++; + if (bad++ > 10) { + fprintf(stderr, + "\nTest aborted after 10 failures\n\n"); + apr_err("apr_connect()", rv); + } + c->state = STATE_UNCONNECTED; + start_connect(c); + continue; + } + else { + c->state = STATE_CONNECTED; + write_request(c); + } + } + else { + write_request(c); + } + } /* * When using a select based poll every time we check the bits @@ -1764,8 +1794,7 @@ #ifdef USE_SSL if (ssl != 1) #endif - if (c->state == STATE_READ || - c->state == STATE_CONNECTING) { + if (c->state == STATE_READ) { apr_pollfd_t new_pollfd; new_pollfd.desc_type = APR_POLL_SOCKET; new_pollfd.reqevents = APR_POLLIN;