ab.c revision 3233d057ad276d823bded5c24c3fd6729ed1a736
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder/* ====================================================================
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * The Apache Software License, Version 1.1
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * Redistribution and use in source and binary forms, with or without
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * modification, are permitted provided that the following conditions
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * 1. Redistributions of source code must retain the above copyright
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * notice, this list of conditions and the following disclaimer.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * 2. Redistributions in binary form must reproduce the above copyright
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * notice, this list of conditions and the following disclaimer in
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * the documentation and/or other materials provided with the
bb4d3b6e93db1495f02de46aff5076862e30517bChristian Maeder * distribution.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * 3. The end-user documentation included with the redistribution,
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * if any, must include the following acknowledgment:
bb4d3b6e93db1495f02de46aff5076862e30517bChristian Maeder * "This product includes software developed by the
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * Apache Software Foundation (http://www.apache.org/)."
bb4d3b6e93db1495f02de46aff5076862e30517bChristian Maeder * Alternately, this acknowledgment may appear in the software itself,
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * if and wherever such third-party acknowledgments normally appear.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * 4. The names "Apache" and "Apache Software Foundation" must
bb4d3b6e93db1495f02de46aff5076862e30517bChristian Maeder * not be used to endorse or promote products derived from this
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * software without prior written permission. For written
21b18016469e574bd145ad07c7b0f02839677cc3Christian Maeder * permission, please contact apache@apache.org.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * 5. Products derived from this software may not be called "Apache",
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * nor may "Apache" appear in their name, without prior written
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * permission of the Apache Software Foundation.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * SUCH DAMAGE.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * ====================================================================
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * This software consists of voluntary contributions made by many
21b18016469e574bd145ad07c7b0f02839677cc3Christian Maeder * individuals on behalf of the Apache Software Foundation. For more
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * information on the Apache Software Foundation, please see
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * Portions of this software are based upon public domain software
7862e8fb34d79382e93b45ce894acdd928da8a51Christian Maeder * originally written at the National Center for Supercomputing Applications,
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder * University of Illinois, Urbana-Champaign.
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder ** This program is based on ZeusBench V1.0 written by Adam Twiss
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder ** which is Copyright (c) 1996 by Zeus Technology Ltd. http://www.zeustech.net/
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder ** This software is provided "as is" and any express or implied waranties,
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder ** including but not limited to, the implied warranties of merchantability and
7862e8fb34d79382e93b45ce894acdd928da8a51Christian Maeder ** fitness for a particular purpose are disclaimed. In no event shall
cf7e0d6750e408ddb47545d6b8349a70cf0b47afChristian Maeder ** Zeus Technology Ltd. be liable for any direct, indirect, incidental, special,
bb4d3b6e93db1495f02de46aff5076862e30517bChristian Maeder ** exemplary, or consequential damaged (including, but not limited to,
bb4d3b6e93db1495f02de46aff5076862e30517bChristian Maeder ** procurement of substitute good or services; loss of use, data, or profits;
21b18016469e574bd145ad07c7b0f02839677cc3Christian Maeder ** or business interruption) however caused and on theory of liability. Whether
21b18016469e574bd145ad07c7b0f02839677cc3Christian Maeder ** in contract, strict liability or tort (including negligence or otherwise)
21b18016469e574bd145ad07c7b0f02839677cc3Christian Maeder ** arising in any way out of the use of this software, even if advised of the
7862e8fb34d79382e93b45ce894acdd928da8a51Christian Maeder ** possibility of such damage.
#define NOT_ASCII
#define BSD_COMP
#include "apr.h"
#include "apr_strings.h"
#include "apr_network_io.h"
#include "apr_file_io.h"
#include "apr_time.h"
#include "apr_getopt.h"
#include "apr_general.h"
#include "apr_lib.h"
#if APR_HAVE_STDIO_H
#include <stdlib.h>
#include "apr_base64.h"
#ifdef NOT_ASCII
#include "apr_xlate.h"
#include <string.h>
#if APR_HAVE_STDIO_H
#include <stdio.h>
#include <stdlib.h>
#if APR_HAVE_CTYPE_H
#include <ctype.h>
#define STATE_UNCONNECTED 0
struct connection {
int state;
int socknum;
struct data {
#define ap_min(a,b) ((a)<(b))?(a):(b)
#define ap_max(a,b) ((a)>(b))?(a):(b)
const char *tablestring;
const char *trstring;
const char *tdstring;
int err_response = 0;
#ifdef NOT_ASCII
static void err(char *s)
if (posting) {
static void output_results(void)
int timetaken;
if (bad)
if (err_response)
if (keepalive)
if (posting)
if (timetaken) {
if (posting>0) {
for (i = 0; i < requests; i++) {
static void output_html_results(void)
int timetaken;
if (bad)
if (err_response)
if (keepalive)
if (posting>0)
if (timetaken) {
if (posting>0) {
for (i = 0; i < requests; i++) {
c->read = 0;
c->bread = 0;
c->keepalive = 0;
c->cbx = 0;
c->gotheader = 0;
!= APR_SUCCESS) {
err_conn++;
start_connect(c);
started++;
write_request(c);
bad ++;
err_length++;
struct data s;
start_connect(c);
apr_size_t r;
char *part;
r = sizeof(buffer);
good++;
close_connection(c);
c->read += r;
totalread += 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 (!use_html) {
if (!posting) {
path,
path,
#ifdef NOT_ASCII
for (i = 0; i < concurrency; i++) {
apr_int32_t n;
n = concurrency;
for (i = 0; i < concurrency; i++) {
bad++;
err_except++;
if (use_html)
static void copyright(void)
if (!use_html) {
printf(" This is ApacheBench, Version %s <i><%s></i> apache-2.0<br>\n", AB_VERSION, "$Revision: 1.57 $");
char *cp;
char *scope_id;
return rv;
if (!postdata) {
return APR_ENOMEM;
return rv;
length);
return APR_EINVAL;
static void terminate(void)
const char *optarg;
#ifdef NOT_ASCII
if (status) {
if (status) {
if (status) {
if (!requests) {
if (posting != 0)
else if (postdata) {
exit(r);
optarg++;
optarg++;
copyright();
copyright();
test();