ab.c revision 8e51f305b81011c418eae9c15320a06b6df037da
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder/* Copyright 1999-2004 The Apache Software Foundation
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * Licensed under the Apache License, Version 2.0 (the "License");
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * you may not use this file except in compliance with the License.
d71c501e69da3973406558162ad439da2b3464d6Christian Maeder * You may obtain a copy of the License at
d71c501e69da3973406558162ad439da2b3464d6Christian Maeder * http://www.apache.org/licenses/LICENSE-2.0
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * Unless required by applicable law or agreed to in writing, software
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder * distributed under the License is distributed on an "AS IS" BASIS,
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder * See the License for the specific language governing permissions and
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder * limitations under the License.
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** This program is based on ZeusBench V1.0 written by Adam Twiss
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** which is Copyright (c) 1996 by Zeus Technology Ltd. http://www.zeustech.net/
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** This software is provided "as is" and any express or implied waranties,
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** including but not limited to, the implied warranties of merchantability and
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** fitness for a particular purpose are disclaimed. In no event shall
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** Zeus Technology Ltd. be liable for any direct, indirect, incidental, special,
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** exemplary, or consequential damaged (including, but not limited to,
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** procurement of substitute good or services; loss of use, data, or profits;
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** or business interruption) however caused and on theory of liability. Whether
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** in contract, strict liability or tort (including negligence or otherwise)
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** arising in any way out of the use of this software, even if advised of the
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** possibility of such damage.
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** - Originally written by Adam Twiss <adam@zeus.co.uk>, March 1996
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** with input from Mike Belshe <mbelshe@netscape.com> and
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** Michael Campanella <campanella@stevms.enet.dec.com>
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** - Enhanced by Dean Gaudet <dgaudet@apache.org>, November 1997
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** - Cleaned up by Ralf S. Engelschall <rse@apache.org>, March 1998
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** - POST and verbosity by Kurt Sussman <kls@merlot.com>, August 1998
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** - HTML table output added by David N. Welton <davidw@prosa.it>, January 1999
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** - Added Cookie, Arbitrary header and auth support. <dirkx@webweaving.org>, April 1999
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** Version 1.3d
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** - Increased version number - as some of the socket/error handling has
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** fundamentally changed - and will give fundamentally different results
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** in situations where a server is dropping requests. Therefore you can
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** no longer compare results of AB as easily. Hence the inc of the version.
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** They should be closer to the truth though. Sander & <dirkx@covalent.net>, End 2000.
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** - Fixed proxy functionality, added median/mean statistics, added gnuplot
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** output option, added _experimental/rudimentary_ SSL support. Added
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** confidence guestimators and warnings. Sander & <dirkx@covalent.net>, End 2000
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** - Fixed serious int overflow issues which would cause realistic (longer
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** than a few minutes) run's to have wrong (but believable) results. Added
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** trapping of connection errors which influenced measurements.
ed0055e8e720ca2d07e857e7852de91d47fab9e7Christian Maeder ** Contributed by Sander Temme, Early 2001
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** Version 1.3e
ed0055e8e720ca2d07e857e7852de91d47fab9e7Christian Maeder ** - Changed timeout behavour during write to work whilst the sockets
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** are filling up and apr_write() does writes a few - but not all.
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** This will potentially change results. <dirkx@webweaving.org>, April 2001
3db8b71dd1ccc662325b96a5ee8f351ace0293baChristian Maeder ** Version 2.0.36-dev
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** Improvements to concurrent processing:
af1cb109bce240bcafe3823df022d6088cbfc438Christian Maeder ** - Enabled non-blocking connect()s.
3db8b71dd1ccc662325b96a5ee8f351ace0293baChristian Maeder ** - Prevent blocking calls to apr_socket_recv() (thereby allowing AB to
3db8b71dd1ccc662325b96a5ee8f351ace0293baChristian Maeder ** manage its entire set of socket descriptors).
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** - Any error returned from apr_socket_recv() that is not EAGAIN or EOF
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** is now treated as fatal.
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** Contributed by Aaron Bannert, April 24, 2002
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** Version 2.0.36-2
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** Internalized the version string - this string is part
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder ** of the Agent: header and the result output.
9d3c461220f8076ef80ca48f7b0574ded9b23e7aChristian Maeder ** Version 2.0.37-dev
9d3c461220f8076ef80ca48f7b0574ded9b23e7aChristian Maeder ** Adopted SSL code by Madhu Mathihalli <madhusudan_mathihalli@hp.com>
3db8b71dd1ccc662325b96a5ee8f351ace0293baChristian Maeder ** [PATCH] ab with SSL support Posted Wed, 15 Aug 2001 20:55:06 GMT
3db8b71dd1ccc662325b96a5ee8f351ace0293baChristian Maeder ** Introduces four 'if (int == value)' tests per non-ssl request.
af1cb109bce240bcafe3823df022d6088cbfc438Christian Maeder ** Version 2.0.40-dev
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** Switched to the new abstract pollset API, allowing ab to
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder ** take advantage of future apr_pollset_t scalability improvements.
ed0055e8e720ca2d07e857e7852de91d47fab9e7Christian Maeder ** Contributed by Brian Pane, August 31, 2002
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder/* Note: this version string should start with \d+[\d\.]* and be a valid
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * string for an HTTP Agent: header when prefixed with 'ApacheBench/'.
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * It should reflect the version of AB - and not that of the apache server
ce59e0cc5c7221245ed323290bfccbda4ee32dd9Christian Maeder * it happens to accompany. And it should be updated or changed whenever
ce59e0cc5c7221245ed323290bfccbda4ee32dd9Christian Maeder * the results are no longer fundamentally comparable to the results of
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * a previous version of ab. Either due to a change in the logic of
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder * ab - or to due to a change in the distribution it is compiled with
af1cb109bce240bcafe3823df022d6088cbfc438Christian Maeder * (such as an APR change in for example blocking).
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * - has various other poor buffer attacks related to the lazy parsing of
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * response headers from the server
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * - doesn't implement much of HTTP/1.x, only accepts certain forms of
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * - (performance problem) heavy use of strstr shows up top in profile
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * only an issue for loopback usage
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder/* -------------------------------------------------------------------- */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder/* Hmmm... This source code isn't being compiled in ASCII.
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * In order for data that flows over the network to make
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * sense, we need to translate to/from ASCII.
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder/* affects include files on Solaris */
3db8b71dd1ccc662325b96a5ee8f351ace0293baChristian Maeder/* Libraries for RSA SSL-C */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder/* Libraries on most systems.. */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder/* ------------------- DEFINITIONS -------------------------- */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder#define AB_MAX APR_INT64_C(0x7fffffffffffffff)
ed0055e8e720ca2d07e857e7852de91d47fab9e7Christian Maeder/* maximum number of requests on a time limited test */
3db8b71dd1ccc662325b96a5ee8f351ace0293baChristian Maeder/* good old state hostname */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder#define STATE_CONNECTING 1 /* TCP connect initiated, but we don't
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * know if it worked yet
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder#define STATE_CONNECTED 2 /* we know TCP connect completed */
1da2d3de72cd19f22820492bc832c9964762a64eChristian Maeder apr_size_t read; /* amount of bytes read */
1da2d3de72cd19f22820492bc832c9964762a64eChristian Maeder apr_size_t bread; /* amount of body read */
1da2d3de72cd19f22820492bc832c9964762a64eChristian Maeder apr_size_t rwrite, rwrote; /* keep pointers in what we write - across
31c6978fd9066c9d2c3c98c950f7abbe89112522Christian Maeder apr_size_t length; /* Content-Length value used for keep-alive */
af1cb109bce240bcafe3823df022d6088cbfc438Christian Maeder char cbuff[CBUFFSIZE]; /* a buffer to store server response header */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder int keepalive; /* non-zero if a keep-alive request */
162a689da386fc8ddbbe47bcae83eaca4fc8dbc0Christian Maeder int gotheader; /* non-zero if we have the entire header in
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder apr_time_t start, /* Start of connection */
ed0055e8e720ca2d07e857e7852de91d47fab9e7Christian Maeder /* XXXX insert SSL timings */
ed0055e8e720ca2d07e857e7852de91d47fab9e7Christian Maeder apr_time_t starttime; /* start time of connection in seconds since
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * Jan. 1, 1970 */
ed0055e8e720ca2d07e857e7852de91d47fab9e7Christian Maeder apr_interval_time_t waittime; /* Between writing request and reading
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder * response */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder apr_interval_time_t ctime; /* time in ms to connect */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder apr_interval_time_t time; /* time in ms for connection */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder#define ap_min(a,b) ((a)<(b))?(a):(b)
31c6978fd9066c9d2c3c98c950f7abbe89112522Christian Maeder#define ap_max(a,b) ((a)>(b))?(a):(b)
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder/* --------------------- GLOBALS ---------------------------- */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maederint verbosity = 0; /* no verbosity by default */
31c6978fd9066c9d2c3c98c950f7abbe89112522Christian Maederint requests = 1; /* Number of requests to make */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maederint heartbeatres = 100; /* How often do we say we're alive */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maederint concurrency = 1; /* Number of multiple requests to make */
af1cb109bce240bcafe3823df022d6088cbfc438Christian Maederint percentile = 1; /* Show percentile served */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maederint confidence = 1; /* Show confidence estimator and warnings */
ce59e0cc5c7221245ed323290bfccbda4ee32dd9Christian Maederint keepalive = 0; /* try and do keepalive connections */
ce59e0cc5c7221245ed323290bfccbda4ee32dd9Christian Maederchar servername[1024]; /* name that server reports */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maederchar *host_field; /* value of "Host:" header field */
3db8b71dd1ccc662325b96a5ee8f351ace0293baChristian Maederchar postfile[1024]; /* name of file containing post data */
3db8b71dd1ccc662325b96a5ee8f351ace0293baChristian Maederchar *postdata; /* *buffer containing data from postfile */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maederapr_size_t postlen = 0; /* length of data to be POSTed */
ed0055e8e720ca2d07e857e7852de91d47fab9e7Christian Maederchar content_type[1024]; /* content type to put in POST header */
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder *auth, /* optional (basic/uuencoded) auhentication */
d71c501e69da3973406558162ad439da2b3464d6Christian Maederapr_interval_time_t aprtimeout = apr_time_from_sec(30); /* timeout value */
d71c501e69da3973406558162ad439da2b3464d6Christian Maeder * XXX - this is now a per read/write transact type of value
d71c501e69da3973406558162ad439da2b3464d6Christian Maederint use_html = 0; /* use html in the report */
d71c501e69da3973406558162ad439da2b3464d6Christian Maederapr_size_t doclen = 0; /* the length the document should be */
d71c501e69da3973406558162ad439da2b3464d6Christian Maederlong started = 0; /* number of requests started, so no excess */
d71c501e69da3973406558162ad439da2b3464d6Christian Maederlong totalread = 0; /* total number of bytes read */
d71c501e69da3973406558162ad439da2b3464d6Christian Maederlong totalbread = 0; /* totoal amount of entity body read */
d71c501e69da3973406558162ad439da2b3464d6Christian Maederlong totalposted = 0; /* total number of bytes posted, inc. headers */
d71c501e69da3973406558162ad439da2b3464d6Christian Maederlong done = 0; /* number of requests we have done */
d71c501e69da3973406558162ad439da2b3464d6Christian Maederlong doneka = 0; /* number of keep alive connections done */
d71c501e69da3973406558162ad439da2b3464d6Christian Maederlong good = 0, bad = 0; /* number of good and bad requests */
d71c501e69da3973406558162ad439da2b3464d6Christian Maederlong epipe = 0; /* number of broken pipe writes */
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maederstatic void write_request(struct connection * c);
162a689da386fc8ddbbe47bcae83eaca4fc8dbc0Christian Maeder/* store error cases */
af1cb109bce240bcafe3823df022d6088cbfc438Christian Maederint err_length = 0, err_conn = 0, err_except = 0;
af1cb109bce240bcafe3823df022d6088cbfc438Christian Maeder/* global request (and its length) */
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder/* one global throw-away buffer to read stuff into */
ed0055e8e720ca2d07e857e7852de91d47fab9e7Christian Maeder/* interesting percentiles */
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maederint percs[] = {50, 66, 75, 80, 90, 95, 98, 99, 100};
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maederstruct connection *con; /* connection array */
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maederstruct data *stats; /* date for each request */
3db8b71dd1ccc662325b96a5ee8f351ace0293baChristian Maederstatic void close_connection(struct connection * c);
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder/* --------------------------------------------------------- */
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder/* simple little function to write an error string and exit */
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maederstatic void err(char *s)
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder printf("Total of %ld requests completed\n" , done);
3db8b71dd1ccc662325b96a5ee8f351ace0293baChristian Maeder/* simple little function to write an APR error string and exit */
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maederstatic void apr_err(char *s, apr_status_t rv)
f09bc2a9244ed29b02ec8dd58a3040f8acb467baChristian Maeder "%s: %s (%d)\n",
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder printf("Total of %ld requests completed\n" , done);
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder * To ensure thread-safetyness in OpenSSL - work in progress
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maederstatic void ssl_util_thr_lock(int mode, int type,
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maederstatic unsigned long ssl_util_thr_id(void)
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder /* OpenSSL needs this to return an unsigned long. On OS/390, the pthread
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder * id is a structure twice that big. Use the TCB pointer instead as a
3db8b71dd1ccc662325b96a5ee8f351ace0293baChristian Maeder * unique unsigned long.
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder unsigned long PSATOLD;
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder return (unsigned long) apr_os_thread_current();
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maederstatic apr_status_t ssl_util_thread_cleanup(void *data)
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder /* Let the registered mutex cleanups do their own thing
af1cb109bce240bcafe3823df022d6088cbfc438Christian Maeder lock_cs = apr_palloc(p, lock_num_locks * sizeof(*lock_cs));
ce59e0cc5c7221245ed323290bfccbda4ee32dd9Christian Maeder for (i = 0; i < lock_num_locks; i++) {
ce59e0cc5c7221245ed323290bfccbda4ee32dd9Christian Maeder apr_thread_mutex_create(&(lock_cs[i]), APR_THREAD_MUTEX_DEFAULT, p);
798a3d6fdcb8c17b0bc3502a150be75c9ec8799bChristian Maeder CRYPTO_set_locking_callback(ssl_util_thr_lock);
ce59e0cc5c7221245ed323290bfccbda4ee32dd9Christian Maeder apr_pool_cleanup_register(p, NULL, ssl_util_thread_cleanup,
ce59e0cc5c7221245ed323290bfccbda4ee32dd9Christian Maeder/* --------------------------------------------------------- */
ce59e0cc5c7221245ed323290bfccbda4ee32dd9Christian Maeder/* write out request to a connection - assumes we can write
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder * (small) request out in one go into our new socket buffer
ce59e0cc5c7221245ed323290bfccbda4ee32dd9Christian Maederstatic long ssl_print_cb(BIO *bio,int cmd,const char *argp,int argi,long argl,long ret)
ed0055e8e720ca2d07e857e7852de91d47fab9e7Christian Maeder BIO_printf(out,"read from %08X [%08lX] (%d bytes => %ld (0x%X))\n",
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder else if (cmd == (BIO_CB_WRITE|BIO_CB_RETURN))
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder BIO_printf(out,"write to %08X [%08lX] (%d bytes => %ld (0x%X))\n",
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maederstatic int ssl_rand_choosenum(int l, int h)
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder (((double)(rand()%RAND_MAX)/RAND_MAX)*(h-l)));
bd8ff5b5f66be563e5be9d3a0c069e32d06f331cChristian Maeder if (i < l) i = l;
46bf8457679e3dd601af7e35cc0966642ba09794Christian Maeder if (i > h) i = h;
static void ssl_rand_seed(void)
int nDone = 0;
time_t t;
l = sizeof(time_t);
RAND_seed((unsigned char *)&t, l);
nDone += l;
l = sizeof(pid_t);
nDone += l;
SSL_CIPHER *c;
#ifdef RSAREF
c->read = 0;
c->bread = 0;
c->keepalive = 0;
c->cbx = 0;
c->gotheader = 0;
c->rwrite = 0;
if (c->ctx)
while (!hdone)
case SSL_ERROR_NONE:
case SSL_ERROR_SSL:
case SSL_ERROR_SYSCALL:
err_conn++;
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
case SSL_ERROR_WANT_CONNECT:
c->rwrite = 0;
case SSL_ERROR_ZERO_RETURN:
#ifdef RSAREF
#ifdef RSAREF
started++;
write_request(c);
if (c->rwrite == 0) {
#ifdef USE_SSL
c->rwrote = 0;
if (posting)
close_connection(c);
#ifdef USE_SSL
if (e_ssl != l)
close_connection (c);
l = e_ssl;
if (l == c->rwrite)
#ifdef USE_SSL
if (e != APR_SUCCESS) {
if (!APR_STATUS_IS_EAGAIN(e)) {
epipe++;
close_connection(c);
c->rwrote += l;
c->rwrite -= l;
#ifdef USE_SSL
static void output_results(void)
float timetaken;
if (bad)
if (err_response)
if (keepalive)
if (posting > 0)
if (timetaken) {
if (posting > 0) {
if (requests) {
for (i = 0; i < requests; i++) {
for (i = 0; i < requests; i++) {
sdtot += a * a;
sdcon += a * a;
sdd += a * a;
sdwait += a * a;
if (gnuplot) {
if (!out) {
for (i = 0; i < requests; i++) {
fprintf(out, "%s\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\n",
diff,
(int (*) (const void *, const void *)) compradre);
(int (*) (const void *, const void *)) compri);
(int (*) (const void *, const void *)) compwait);
(int (*) (const void *, const void *)) comprando);
if (confidence) {
#define CONF_FMT_STRING "%5" APR_TIME_T_FMT " %4d %5.1f %6" APR_TIME_T_FMT " %7" APR_TIME_T_FMT "\n"
else if (d > sd ) \
for (i = 0; i < sizeof(percs) / sizeof(int); i++)
if (percs[i] <= 0)
if (csvperc) {
if (!out) {
apr_time_t t;
static void output_html_results(void)
long timetaken;
if (bad)
if (err_response)
if (keepalive)
if (posting > 0)
if (timetaken) {
if (posting > 0) {
for (i = 0; i < requests; i++) {
#ifdef USE_SSL
c->read = 0;
c->bread = 0;
c->keepalive = 0;
c->cbx = 0;
c->gotheader = 0;
c->rwrite = 0;
if (c->ctx)
!= APR_SUCCESS) {
c->rwrite = 0;
err_conn++;
start_connect(c);
started++;
write_request(c);
if (good)
bad++;
err_length++;
struct data s;
#ifdef USE_SSL
start_connect(c);
apr_size_t r;
char *part;
r = sizeof(buffer);
#ifdef USE_SSL
if (status <= 0) {
close_connection(c);
r = status;
good++;
close_connection(c);
#ifdef USE_SSL
totalread += r;
if (c->read == 0) {
c->read += r;
if (!c->gotheader) {
#ifdef NOT_ASCII
if (space) {
err_response++;
start_connect(c);
if (!good) {
q = servername;
err_response++;
if (keepalive &&
char *cl;
if (!cl)
if (cl) {
c->bread += r;
totalbread += r;
good++;
doneka++;
bad++;
err_length++;
struct data s;
c->keepalive = 0;
c->length = 0;
c->gotheader = 0;
c->cbx = 0;
write_request(c);
static void test(void)
#ifdef NOT_ASCII
if (isproxy) {
if (!use_html) {
if (isproxy)
if (posting <= 0) {
if (!buff) {
#ifdef NOT_ASCII
#ifdef USE_SSL
!= APR_SUCCESS) {
for (i = 0; i < concurrency; i++) {
apr_int32_t n;
n = concurrency;
#ifdef USE_SSL
struct connection *c;
#ifdef USE_SSL
if (ssl)
c = &con[i];
#ifdef USE_SSL
read_connection(c);
bad++;
err_except++;
start_connect(c);
err_conn++;
start_connect(c);
write_request(c);
write_request(c);
#ifdef USE_SSL
if (heartbeatres)
if (use_html)
static void copyright(void)
if (!use_html) {
printf(" This is ApacheBench, Version %s <i><%s></i> apache-2.0<br>\n", AP_AB_BASEREVISION, "$Revision: 1.139 $");
#ifdef USE_SSL
#ifdef USE_SSL
char *cp;
char *scope_id;
#ifdef USE_SSL
ssl = 0;
#ifdef USE_SSL
#ifdef USE_SSL
#ifdef USE_SSL
return rv;
if (!postdata) {
return APR_ENOMEM;
return rv;
length);
return APR_EINVAL;
const char *optarg;
#ifdef NOT_ASCII
if (status) {
if (status) {
if (status) {
#ifdef USE_SSL
#ifdef USE_SSL
if (!requests) {
heartbeatres = 0;
percentile = 0;
confidence = 0;
if (posting != 0)
else if (postdata) {
exit(r);
optarg++;
optarg++;
copyright();
heartbeatres = 0;
#ifdef USE_SSL
#ifdef RSAREF
#ifdef USE_THREADS
#ifdef SIGPIPE
copyright();
test();