> I'll reintroduce the trimmed STATUS and src/CHANGES notes as soon as cvs's
> email catches up.
Shame - coordination crossed there while I am trying to catch up with my
mail after traveling; find attached the same patch which -Wall's cleanly
and has been tested over the weekend on MacOSX, Solaris 8 and FreeBSD
4with and without USE_SSL/openssl.
Feel free to commit it now or later; or let me know when I should commit.
The differnece with the previous patch is an isspace((int)*optarg); i.e.
the (int) cast of the car; the addition of a ':' in the error printf.
Dw
Index: ab.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/support/ab.c,v
retrieving revision 1.50
diff -u -r1.50 ab.c
--- ab.c 2001/05/10 17:25:00 1.50
+++ ab.c 2001/05/15 19:25:29
@@ -227,6 +227,7 @@
#define ap_min(a,b) ((a)<(b))?(a):(b)
#define ap_max(a,b) ((a)>(b))?(a):(b)
+#define _rnd(x) ((long)(x+0.5))
/* --------------------- GLOBALS ---------------------------- */
@@ -307,7 +308,10 @@
#endif
static void close_connection(struct connection * c);
+#if NO_WRITEV || USE_SSL
static void s_write(struct connection * c, char *buff, int len);
+#endif
+
/* --------------------------------------------------------- */
/* simple little function to perror and exit */
@@ -318,9 +322,9 @@
perror(s);
}
else {
- printf("%s", s);
+ fprintf(stderr,"%s", s);
}
- exit(errno);
+ exit(errno ? errno : 1);
}
/* --------------------------------------------------------- */
@@ -369,6 +373,7 @@
/* Do actual data writing */
+#if NO_WRITEV || USE_SSL
static void s_write(struct connection * c, char *buff, int len)
{
do {
@@ -399,7 +404,13 @@
close_connection(c);
return;
default:
- perror("write");
+#if USE_SSL
+ if (ssl) {
+ fprintf(stderr,"Error writing: ");
+ ERR_print_errors_fp(stderr);
+ } else
+#endif
+ perror("write");
exit(1);
}
}
@@ -411,6 +422,7 @@
};
} while (len > 0);
}
+#endif
/* --------------------------------------------------------- */
@@ -499,22 +511,22 @@
printf("Document Length: %d bytes\n", doclen);
printf("\n");
printf("Concurrency Level: %d\n", concurrency);
- printf("Time taken for tests: %d.%03d seconds\n",
+ printf("Time taken for tests: %ld.%03ld seconds\n",
timetaken / 1000, timetaken % 1000);
- printf("Complete requests: %d\n", done);
- printf("Failed requests: %d\n", bad);
+ printf("Complete requests: %ld\n", done);
+ printf("Failed requests: %ld\n", bad);
if (bad)
printf(" (Connect: %d, Length: %d, Exceptions: %d)\n",
err_conn, err_length, err_except);
- printf("Broken pipe errors: %d\n", epipe);
+ printf("Broken pipe errors: %ld\n", epipe);
if (err_response)
printf("Non-2xx responses: %d\n", err_response);
if (keepalive)
- printf("Keep-Alive requests: %d\n", doneka);
- printf("Total transferred: %d bytes\n", totalread);
+ printf("Keep-Alive requests: %ld\n", doneka);
+ printf("Total transferred: %ld bytes\n", totalread);
if (posting > 0)
- printf("Total POSTed: %d\n", totalposted);
- printf("HTML transferred: %d bytes\n", totalbread);
+ printf("Total POSTed: %ld\n", totalposted);
+ printf("HTML transferred: %ld bytes\n", totalbread);
/* avoid divide by zero */
if (timetaken) {
@@ -582,20 +594,20 @@
if (gnuplot) {
FILE *out = fopen(gnuplot, "w");
long i;
- time_t sttime;
- char *tmstring;
if (!out) {
perror("Cannot open gnuplot output file");
exit(1);
};
fprintf(out, "starttime\tseconds\tctime\tdtime\tttime\twait\n");
for (i = 0; i < requests; i++) {
+ time_t sttime;
+ char *tmstring;
sttime = stats[i].starttime;
tmstring = ctime(&sttime);
tmstring[strlen(tmstring) - 1] = '\0'; /* ctime returns a
* string with a
* trailing newline */
- fprintf(out, "%s\t%d\t%d\t%d\t%d\t%d\n",
+ fprintf(out, "%s\t%ld\t%ld\t%ld\t%ld\t%ld\n",
tmstring,
sttime,
stats[i].ctime,
@@ -645,13 +657,13 @@
if (confidence) {
printf(" min mean[+/-sd] median max\n");
- printf("Connect: %5d %5d %6.1f %5d %5d\n",
- mincon, (int) (totalcon + 0.5), sdcon, meancon, maxcon);
- printf("Processing: %5d %5d %6.1f %5d %5d\n",
- mind, (int) (totald + 0.5), sdd, meand, maxd);
- printf("Waiting: %5d %5d %6.1f %5d %5d\n",
- minwait, (int) (totalwait + 0.5), sdwait, meanwait, maxwait);
- printf("Total: %5d %5d %6.1f %5d %5d\n", mintot, (int) (total +
0.5), sdtot, meantot, maxtot);
+ printf("Connect: %5ld %5ld %6.1f %5ld %5ld\n",
+ mincon, _rnd(totalcon), sdcon, meancon, maxcon);
+ printf("Processing: %5ld %5ld %6.1f %5ld %5ld\n",
+ mind, _rnd(totald), sdd, meand, maxd);
+ printf("Waiting: %5ld %5ld %6.1f %5ld %5ld\n",
+ minwait, _rnd(totalwait), sdwait, meanwait, maxwait);
+ printf("Total: %5ld %5ld %6.1f %5ld %5ld\n", mintot, _rnd(total),
+sdtot, meantot, maxtot);
#define SANE(what,avg,mean,sd) \
{ \
@@ -671,30 +683,28 @@
}
else {
printf(" min avg max\n");
- printf("Connect: %5d %5d %5d\n", mincon, (int) (totalcon + 0.5),
maxcon);
- printf("Processing: %5d %5d %5d\n", mind, (int) (totald + 0.5), maxd);
- printf("Total: %5d %5d %5d\n", mintot, (int) (0.5 + total), maxtot);
+ printf("Connect: %5ld %5ld %5ld\n", mincon, _rnd(totalcon), maxcon);
+ printf("Processing: %5ld %5ld %5ld\n", mind, _rnd(totald), maxd);
+ printf("Total: %5ld %5ld %5ld\n", mintot, _rnd(total), maxtot);
};
/* Sorted on total connect times */
if (percentile && (requests > 1)) {
printf("\nPercentage of the requests served within a certain time (ms)\n");
- printf(" 50%% %5d\n", stats[(int) (requests * 0.50)].time);
- printf(" 66%% %5d\n", stats[(int) (requests * 0.66)].time);
- printf(" 75%% %5d\n", stats[(int) (requests * 0.75)].time);
- printf(" 80%% %5d\n", stats[(int) (requests * 0.80)].time);
- printf(" 90%% %5d\n", stats[(int) (requests * 0.90)].time);
- printf(" 95%% %5d\n", stats[(int) (requests * 0.95)].time);
- printf(" 98%% %5d\n", stats[(int) (requests * 0.98)].time);
- printf(" 99%% %5d\n", stats[(int) (requests * 0.99)].time);
- printf(" 100%% %5d (last request)\n", stats[(int) (requests - 1)].time);
+ printf(" 50%% %5ld\n", stats[(int) (requests * 0.50)].time);
+ printf(" 66%% %5ld\n", stats[(int) (requests * 0.66)].time);
+ printf(" 75%% %5ld\n", stats[(int) (requests * 0.75)].time);
+ printf(" 80%% %5ld\n", stats[(int) (requests * 0.80)].time);
+ printf(" 90%% %5ld\n", stats[(int) (requests * 0.90)].time);
+ printf(" 95%% %5ld\n", stats[(int) (requests * 0.95)].time);
+ printf(" 98%% %5ld\n", stats[(int) (requests * 0.98)].time);
+ printf(" 99%% %5ld\n", stats[(int) (requests * 0.99)].time);
+ printf(" 100%% %5ld (last request)\n", stats[(int) (requests - 1)].time);
\
};
if (csvperc) {
FILE *out = fopen(csvperc, "w");
long i;
- time_t sttime;
- char *tmstring;
if (!out) {
perror("Cannot open CSV output file");
exit(1);
@@ -708,7 +718,7 @@
d = stats[requests - 1].time;
else
d = stats[(int) (0.5 + requests * i / 100.0)].time;
- fprintf(out, "%d,%d\n", i, d);
+ fprintf(out, "%ld,%f\n", i, d);
}
fclose(out);
};
@@ -746,13 +756,13 @@
"<td colspan=2 %s>%d</td></tr>\n",
trstring, tdstring, tdstring, concurrency);
printf("<tr %s><th colspan=2 %s>Time taken for tests:</th>"
- "<td colspan=2 %s>%d.%03d seconds</td></tr>\n",
+ "<td colspan=2 %s>%ld.%03ld seconds</td></tr>\n",
trstring, tdstring, tdstring, timetaken / 1000, timetaken % 1000);
printf("<tr %s><th colspan=2 %s>Complete requests:</th>"
- "<td colspan=2 %s>%d</td></tr>\n",
+ "<td colspan=2 %s>%ld</td></tr>\n",
trstring, tdstring, tdstring, done);
printf("<tr %s><th colspan=2 %s>Failed requests:</th>"
- "<td colspan=2 %s>%d</td></tr>\n",
+ "<td colspan=2 %s>%ld</td></tr>\n",
trstring, tdstring, tdstring, bad);
if (bad)
printf("<tr %s><td colspan=4 %s > (Connect: %d, Length: %d, Exceptions:
%d)</td></tr>\n",
@@ -763,17 +773,17 @@
trstring, tdstring, tdstring, err_response);
if (keepalive)
printf("<tr %s><th colspan=2 %s>Keep-Alive requests:</th>"
- "<td colspan=2 %s>%d</td></tr>\n",
+ "<td colspan=2 %s>%ld</td></tr>\n",
trstring, tdstring, tdstring, doneka);
printf("<tr %s><th colspan=2 %s>Total transferred:</th>"
- "<td colspan=2 %s>%d bytes</td></tr>\n",
+ "<td colspan=2 %s>%ld bytes</td></tr>\n",
trstring, tdstring, tdstring, totalread);
if (posting > 0)
printf("<tr %s><th colspan=2 %s>Total POSTed:</th>"
- "<td colspan=2 %s>%d</td></tr>\n",
+ "<td colspan=2 %s>%ld</td></tr>\n",
trstring, tdstring, tdstring, totalposted);
printf("<tr %s><th colspan=2 %s>HTML transferred:</th>"
- "<td colspan=2 %s>%d bytes</td></tr>\n",
+ "<td colspan=2 %s>%ld bytes</td></tr>\n",
trstring, tdstring, tdstring, totalbread);
/* avoid divide by zero */
@@ -817,20 +827,20 @@
printf("<tr %s><th %s> </th> <th %s>min</th> <th %s>avg</th> <th
%s>max</th></tr>\n",
trstring, tdstring, tdstring, tdstring, tdstring);
printf("<tr %s><th %s>Connect:</th>"
- "<td %s>%5d</td>"
- "<td %s>%5d</td>"
- "<td %s>%5d</td></tr>\n",
+ "<td %s>%5ld</td>"
+ "<td %s>%5ld</td>"
+ "<td %s>%5ld</td></tr>\n",
trstring, tdstring, tdstring, mincon, tdstring, totalcon /
requests, tdstring, maxcon);
printf("<tr %s><th %s>Processing:</th>"
- "<td %s>%5d</td>"
- "<td %s>%5d</td>"
- "<td %s>%5d</td></tr>\n",
+ "<td %s>%5ld</td>"
+ "<td %s>%5ld</td>"
+ "<td %s>%5ld</td></tr>\n",
trstring, tdstring, tdstring, mintot - mincon, tdstring,
(total / requests) - (totalcon / requests), tdstring, maxtot -
maxcon);
printf("<tr %s><th %s>Total:</th>"
- "<td %s>%5d</td>"
- "<td %s>%5d</td>"
- "<td %s>%5d</td></tr>\n",
+ "<td %s>%5ld</td>"
+ "<td %s>%5ld</td>"
+ "<td %s>%5ld</td></tr>\n",
trstring, tdstring, tdstring, mintot, tdstring, total / requests,
tdstring, maxtot);
}
printf("</table>\n");
@@ -897,7 +907,7 @@
};
SSL_set_connect_state(c->ssl);
if ((e = SSL_set_fd(c->ssl, c->fd)) == -1) {
- fprintf(stderr, "SSL fd init failed ")l
+ fprintf(stderr, "SSL fd init failed ");
ERR_print_errors_fp(stderr);
goto bad;
};
@@ -950,8 +960,8 @@
/* save out time */
if (done < requests) {
struct data s;
- if ((done) && (!(done % heartbeatres))) {
- fprintf(stderr, "Completed %d requests\n", done);
+ if ((done) && (heartbeatres) && (!(done % heartbeatres))) {
+ fprintf(stderr, "Completed %ld requests\n", done);
fflush(stderr);
}
gettimeofday(&c->done, 0);
@@ -1129,8 +1139,8 @@
}
if (done < requests) {
struct data s;
- if ((done) && (!(done % heartbeatres))) {
- fprintf(stderr, "Completed %d requests\n", done);
+ if ((done) && (heartbeatres) && (!(done % heartbeatres))) {
+ fprintf(stderr, "Completed %ld requests\n", done);
fflush(stderr);
}
gettimeofday(&c->done, 0);
@@ -1159,7 +1169,7 @@
{
int i; /* loop variable */
- printf("Caught broken pipe signal after %d requests. ", done);
+ printf("Caught broken pipe signal after %ld requests. ", done);
/* This means one of my connections is broken, but which one? */
/* The safe route: close all our connections. */
@@ -1233,7 +1243,9 @@
(isproxy) ? fullurl : path,
VERSION,
keepalive ? "Connection: Keep-Alive\r\n" : "",
- cookie, auth, hostname, hdrs);
+ cookie, auth,
+ proxyhost,
+ hdrs);
}
else {
sprintf(request, "POST %s HTTP/1.0\r\n"
@@ -1245,11 +1257,11 @@
"Content-type: %s\r\n"
"%s"
"\r\n",
- (isproxy) ? fullurl : path,
+ (isproxy) ? fullurl : path,
VERSION,
keepalive ? "Connection: Keep-Alive\r\n" : "",
cookie, auth,
- hostname, postlen,
+ proxyhost, postlen,
(content_type[0]) ? content_type : "text/plain", hdrs);
}
@@ -1307,7 +1319,7 @@
}
if (heartbeatres)
- fprintf(stderr, "Finished %d requests\n", done);
+ fprintf(stderr, "Finished %ld requests\n", done);
else
printf("..done\n");
@@ -1323,14 +1335,14 @@
static void copyright(void)
{
if (!use_html) {
- printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.50 $>
apache-1.3");
+ printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.48 $>
+apache-1.3");
printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd,
http://www.zeustech.net/\n");
printf("Copyright (c) 1998-1999 The Apache Group, http://www.apache.org/\n");
printf("\n");
}
else {
printf("<p>\n");
- printf(" This is ApacheBench, Version %s <i><%s></i> apache-1.3<br>\n",
VERSION, "$Revision: 1.50 $");
+ printf(" This is ApacheBench, Version %s <i><%s></i> apache-1.3<br>\n",
+VERSION, "$Revision: 1.48 $");
printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd,
http://www.zeustech.net/<br>\n");
printf(" Copyright (c) 1998-1999 The Apache Group,
http://www.apache.org/<br>\n");
printf("</p>\n<p>\n");
@@ -1460,7 +1472,6 @@
{
int c, r, l;
char tmp[1024];
-
/* table defaults */
tablestring = "";
trstring = "";
@@ -1546,7 +1557,7 @@
* assume username passwd already to be in colon separated form.
* Ready to be uu-encoded.
*/
- while (isspace(*optarg))
+ while (isspace((int)*optarg))
optarg++;
l = ap_base64encode(tmp, optarg, strlen(optarg));
tmp[l] = '\0';
@@ -1559,7 +1570,7 @@
/*
* assume username passwd already to be in colon separated form.
*/
- while (isspace(*optarg))
+ while (isspace((int)*optarg))
optarg++;
l = ap_base64encode(tmp, optarg, strlen(optarg));
tmp[l] = '\0';
@@ -1574,7 +1585,7 @@
/*
* assume proxy-name[:port]
*/
- if (p = strchr(optarg, ':')) {
+ if ((p = strchr(optarg, ':'))) {
*p = '\0';
p++;
proxyport = atoi(p);
@@ -1631,23 +1642,26 @@
}
if ((heartbeatres) && (requests > 150)) {
- heartbeatres = requests / 10; /* Print line every 10% of requests */
+ heartbeatres = requests / 10; /* Print a line every 10% of requests */
if (heartbeatres < 100)
heartbeatres = 100; /* but never more often than once every 100
* connections. */
}
else
+ /* if there are less than 150 requests; do not show
+ * the little tick/tock dots.
+ */
heartbeatres = 0;
#ifdef USE_SSL
SSL_library_init();
if (!(ctx = SSL_CTX_new(SSLv2_client_method()))) {
- fprintf(stderr, "Could not init SSL CTX");
+ fprintf(stderr, "Could not init SSL CTX: ");
ERR_print_errors_fp(stderr);
exit(1);
}
#endif
- signal(SIGPIPE, SIG_IGN); /* Ignore writes to connections that
+ signal(SIGPIPE, SIG_IGN); /* Ignore writes to connections that
* have been closed at the other end.
* These writes are dealt with in the
* s_write() function. */