--- httpd-2.1.6-alpha/support/ab.c 2005-05-18 00:34:43.000000000 +0900 +++ httpd-2.1.6-alpha.new/support/ab.c 2005-07-12 19:27:37.461352000 +0900 @@ -80,6 +80,10 @@ ** Switched to the new abstract pollset API, allowing ab to ** take advantage of future apr_pollset_t scalability improvements. ** Contributed by Brian Pane, August 31, 2002 + ** + ** Version 2.1.7-dev + ** New SSL code by Masaoki Kobayashi , + ** enables the asynchronous I/O also under SSL connections. **/ /* Note: this version string should start with \d+[\d\.]* and be a valid @@ -91,7 +95,7 @@ * ab - or to due to a change in the distribution it is compiled with * (such as an APR change in for example blocking). */ -#define AP_AB_BASEREVISION "2.0.40-dev" +#define AP_AB_BASEREVISION "2.1.7-dev" /* * BUGS: @@ -234,6 +238,7 @@ int socknum; #ifdef USE_SSL SSL *ssl; + int ssl_polling; #endif }; @@ -403,11 +408,13 @@ (w & SSL_CB_READ ? "read" : "write"), SSL_alert_type_string_long(r), SSL_alert_desc_string_long(r)); - } else if (w & SSL_CB_LOOP) { + } + else if (w & SSL_CB_LOOP) { BIO_printf(bio_err, "SSL/TLS State [%s] %s\n", (SSL_in_connect_init((SSL*)s) ? "connect" : "-"), SSL_state_string_long(s)); - } else if (w & (SSL_CB_HANDSHAKE_START|SSL_CB_HANDSHAKE_DONE)) { + } + else if (w & (SSL_CB_HANDSHAKE_START|SSL_CB_HANDSHAKE_DONE)) { BIO_printf(bio_err, "SSL/TLS Handshake [%s] %s\n", (w & SSL_CB_HANDSHAKE_START ? "Start" : "Done"), SSL_state_string_long(s)); @@ -528,7 +535,8 @@ cert = SSL_get_peer_certificate(c->ssl); if (cert == NULL) { BIO_printf(bio_out, "Anon DH\n"); - } else { + } + else { BIO_printf(bio_out, "Peer certificate\n"); ssl_print_cert_info(bio_out, cert); X509_free(cert); @@ -543,7 +551,6 @@ while (do_next) { int ret, ecode; - apr_pollfd_t new_pollfd; ret = SSL_do_handshake(c->ssl); ecode = SSL_get_error(c->ssl, ret); @@ -575,11 +582,15 @@ do_next = 0; break; case SSL_ERROR_WANT_READ: - new_pollfd.desc_type = APR_POLL_SOCKET; - new_pollfd.reqevents = APR_POLLIN; - new_pollfd.desc.s = c->aprsock; - new_pollfd.client_data = c; - apr_pollset_add(readbits, &new_pollfd); + if (!c->ssl_polling) { + apr_pollfd_t new_pollfd; + new_pollfd.desc_type = APR_POLL_SOCKET; + new_pollfd.reqevents = APR_POLLIN; + new_pollfd.desc.s = c->aprsock; + new_pollfd.client_data = c; + apr_pollset_add(readbits, &new_pollfd); + c->ssl_polling = 1; + } do_next = 0; break; case SSL_ERROR_WANT_WRITE: @@ -666,6 +677,11 @@ totalposted += c->rwrite; c->state = STATE_READ; c->endwrite = apr_time_now(); +#ifdef USE_SSL + /* Do not add the pollset here in ssl connection which is + already been polling */ + if (!c->ssl_polling) +#endif { apr_pollfd_t new_pollfd; new_pollfd.desc_type = APR_POLL_SOCKET; @@ -1135,6 +1151,7 @@ ERR_print_errors(bio_err); exit(1); } + c->ssl_polling = 0; ssl_rand_seed(); apr_os_sock_get(&fd, c->aprsock); bio = BIO_new_socket(fd, BIO_NOCLOSE); @@ -1144,8 +1161,10 @@ BIO_set_callback(bio, ssl_print_cb); BIO_set_callback_arg(bio, bio_err); } - } else { + } + else { c->ssl = NULL; + c->ssl_polling = 0; } #endif if ((rv = apr_socket_connect(c->aprsock, destsa)) != APR_SUCCESS) { @@ -1184,7 +1203,8 @@ #ifdef USE_SSL if (c->ssl) { ssl_proceed_handshake(c); - } else + } + else #endif { write_request(c); @@ -1693,22 +1713,6 @@ write_request(c); } } - - /* - * When using a select based poll every time we check the bits - * are reset. In 1.3's ab we copied the FD_SET's each time - * through, but here we're going to check the state and if the - * connection is in STATE_READ or STATE_CONNECTING we'll add the - * socket back in as APR_POLLIN. - */ - if (c->state == STATE_READ) { - apr_pollfd_t new_pollfd; - new_pollfd.desc_type = APR_POLL_SOCKET; - new_pollfd.reqevents = APR_POLLIN; - new_pollfd.desc.s = c->aprsock; - new_pollfd.client_data = c; - apr_pollset_add(readbits, &new_pollfd); - } } } @@ -1729,14 +1733,14 @@ static void copyright(void) { if (!use_html) { - printf("This is ApacheBench, Version %s\n", AP_AB_BASEREVISION " <$Revision: 1.146 $> apache-2.0"); + printf("This is ApacheBench, Version %s\n", AP_AB_BASEREVISION " apache-2.1"); printf("Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n"); printf("Copyright 1997-2005 The Apache Software Foundation, http://www.apache.org/\n"); printf("\n"); } else { printf("

\n"); - printf(" This is ApacheBench, Version %s <%s> apache-2.0
\n", AP_AB_BASEREVISION, "$Revision: 1.146 $"); + printf(" This is ApacheBench, Version %s apache-2.1
\n", AP_AB_BASEREVISION); printf(" Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
\n"); printf(" Copyright 1997-2005 The Apache Software Foundation, http://www.apache.org/
\n"); printf("

\n

\n"); @@ -1852,7 +1856,8 @@ (port != 80))) { colonhost = apr_psprintf(cntxt,":%d",port); - } else + } + else colonhost = ""; return 0; } @@ -2082,11 +2087,14 @@ case 'f': if (strncasecmp(optarg, "ALL", 3) == 0) { meth = SSLv23_client_method(); - } else if (strncasecmp(optarg, "SSL2", 4) == 0) { + } + else if (strncasecmp(optarg, "SSL2", 4) == 0) { meth = SSLv2_client_method(); - } else if (strncasecmp(optarg, "SSL3", 4) == 0) { + } + else if (strncasecmp(optarg, "SSL3", 4) == 0) { meth = SSLv3_client_method(); - } else if (strncasecmp(optarg, "TLS1", 4) == 0) { + } + else if (strncasecmp(optarg, "TLS1", 4) == 0) { meth = TLSv1_client_method(); } break;