This patch fixes all warnings on FreeBSD and MacOS-X as well as a
potential division by zero problem. What is the status of the tree ? Are
we in full freeze now ?
Dw
Index: ab.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/support/ab.c,v
retrieving revision 1.48
diff -c -r1.48 ab.c
*** ab.c 2001/04/03 01:43:09 1.48
--- ab.c 2001/05/11 04:25:02
***************
*** 227,232 ****
--- 227,233 ----
#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,313 ****
--- 308,317 ----
#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,326 ****
perror(s);
}
else {
! printf("%s", s);
}
! exit(errno);
}
/* --------------------------------------------------------- */
--- 322,330 ----
perror(s);
}
else {
! fprintf(stderr,"%s", s);
}
! exit(errno ? errno : 1);
}
/* --------------------------------------------------------- */
***************
*** 369,374 ****
--- 373,379 ----
/* Do actual data writing */
+ #if NO_WRITEV || USE_SSL
static void s_write(struct connection * c, char *buff, int len)
{
do {
***************
*** 399,405 ****
close_connection(c);
return;
default:
! perror("write");
exit(1);
}
}
--- 404,416 ----
close_connection(c);
return;
default:
! #if USE_SSL
! if (ssl) {
! fprintf(stderr,"Error writing: ");
! ERR_print_errors_fp(stderr);
! } else
! #endif
! perror("write");
exit(1);
}
}
***************
*** 411,416 ****
--- 422,428 ----
};
} while (len > 0);
}
+ #endif
/* --------------------------------------------------------- */
***************
*** 499,520 ****
printf("Document Length: %d bytes\n", doclen);
printf("\n");
printf("Concurrency Level: %d\n", concurrency);
! printf("Time taken for tests: %d.%03d seconds\n",
timetaken / 1000, timetaken % 1000);
! printf("Complete requests: %d\n", done);
! printf("Failed requests: %d\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);
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);
if (posting > 0)
! printf("Total POSTed: %d\n", totalposted);
! printf("HTML transferred: %d bytes\n", totalbread);
/* avoid divide by zero */
if (timetaken) {
--- 511,532 ----
printf("Document Length: %d bytes\n", doclen);
printf("\n");
printf("Concurrency Level: %d\n", concurrency);
! printf("Time taken for tests: %ld.%03ld seconds\n",
timetaken / 1000, timetaken % 1000);
! 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: %ld\n", epipe);
if (err_response)
printf("Non-2xx responses: %d\n", err_response);
if (keepalive)
! printf("Keep-Alive requests: %ld\n", doneka);
! printf("Total transferred: %ld bytes\n", totalread);
if (posting > 0)
! printf("Total POSTed: %ld\n", totalposted);
! printf("HTML transferred: %ld bytes\n", totalbread);
/* avoid divide by zero */
if (timetaken) {
***************
*** 582,601 ****
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++) {
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",
tmstring,
sttime,
stats[i].ctime,
--- 594,613 ----
if (gnuplot) {
FILE *out = fopen(gnuplot, "w");
long i;
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%ld\t%ld\t%ld\t%ld\t%ld\n",
tmstring,
sttime,
stats[i].ctime,
***************
*** 645,657 ****
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);
#define SANE(what,avg,mean,sd) \
{ \
--- 657,669 ----
if (confidence) {
printf(" min mean[+/-sd] median max\n");
! 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,700 ****
}
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);
};
/* 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);
\
};
if (csvperc) {
FILE *out = fopen(csvperc, "w");
long i;
- time_t sttime;
- char *tmstring;
if (!out) {
perror("Cannot open CSV output file");
exit(1);
--- 683,710 ----
}
else {
printf(" min avg max\n");
! 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%% %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;
if (!out) {
perror("Cannot open CSV output file");
exit(1);
***************
*** 708,714 ****
d = stats[requests - 1].time;
else
d = stats[(int) (0.5 + requests * i / 100.0)].time;
! fprintf(out, "%d,%d\n", i, d);
}
fclose(out);
};
--- 718,724 ----
d = stats[requests - 1].time;
else
d = stats[(int) (0.5 + requests * i / 100.0)].time;
! fprintf(out, "%ld,%f\n", i, d);
}
fclose(out);
};
***************
*** 746,758 ****
"<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",
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",
trstring, tdstring, tdstring, done);
printf("<tr %s><th colspan=2 %s>Failed requests:</th>"
! "<td colspan=2 %s>%d</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",
--- 756,768 ----
"<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>%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>%ld</td></tr>\n",
trstring, tdstring, tdstring, done);
printf("<tr %s><th colspan=2 %s>Failed requests:</th>"
! "<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,779 ****
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",
trstring, tdstring, tdstring, doneka);
printf("<tr %s><th colspan=2 %s>Total transferred:</th>"
! "<td colspan=2 %s>%d 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",
trstring, tdstring, tdstring, totalposted);
printf("<tr %s><th colspan=2 %s>HTML transferred:</th>"
! "<td colspan=2 %s>%d bytes</td></tr>\n",
trstring, tdstring, tdstring, totalbread);
/* avoid divide by zero */
--- 773,789 ----
trstring, tdstring, tdstring, err_response);
if (keepalive)
printf("<tr %s><th colspan=2 %s>Keep-Alive requests:</th>"
! "<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>%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>%ld</td></tr>\n",
trstring, tdstring, tdstring, totalposted);
printf("<tr %s><th colspan=2 %s>HTML transferred:</th>"
! "<td colspan=2 %s>%ld bytes</td></tr>\n",
trstring, tdstring, tdstring, totalbread);
/* avoid divide by zero */
***************
*** 817,836 ****
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",
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",
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",
trstring, tdstring, tdstring, mintot, tdstring, total / requests,
tdstring, maxtot);
}
printf("</table>\n");
--- 827,846 ----
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>%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>%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>%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,903 ****
};
SSL_set_connect_state(c->ssl);
if ((e = SSL_set_fd(c->ssl, c->fd)) == -1) {
! fprintf(stderr, "SSL fd init failed ")l
ERR_print_errors_fp(stderr);
goto bad;
};
--- 907,913 ----
};
SSL_set_connect_state(c->ssl);
if ((e = SSL_set_fd(c->ssl, c->fd)) == -1) {
! fprintf(stderr, "SSL fd init failed ");
ERR_print_errors_fp(stderr);
goto bad;
};
***************
*** 950,957 ****
/* save out time */
if (done < requests) {
struct data s;
! if ((done) && (!(done % heartbeatres))) {
! fprintf(stderr, "Completed %d requests\n", done);
fflush(stderr);
}
gettimeofday(&c->done, 0);
--- 960,967 ----
/* save out time */
if (done < requests) {
struct data s;
! if ((done) && (heartbeatres) && (!(done % heartbeatres))) {
! fprintf(stderr, "Completed %ld requests\n", done);
fflush(stderr);
}
gettimeofday(&c->done, 0);
***************
*** 1129,1136 ****
}
if (done < requests) {
struct data s;
! if ((done) && (!(done % heartbeatres))) {
! fprintf(stderr, "Completed %d requests\n", done);
fflush(stderr);
}
gettimeofday(&c->done, 0);
--- 1139,1146 ----
}
if (done < requests) {
struct data s;
! if ((done) && (heartbeatres) && (!(done % heartbeatres))) {
! fprintf(stderr, "Completed %ld requests\n", done);
fflush(stderr);
}
gettimeofday(&c->done, 0);
***************
*** 1159,1165 ****
{
int i; /* loop variable */
! printf("Caught broken pipe signal after %d requests. ", done);
/* This means one of my connections is broken, but which one? */
/* The safe route: close all our connections. */
--- 1169,1175 ----
{
int i; /* loop variable */
! 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. */
***************
*** 1307,1313 ****
}
if (heartbeatres)
! fprintf(stderr, "Finished %d requests\n", done);
else
printf("..done\n");
--- 1317,1323 ----
}
if (heartbeatres)
! fprintf(stderr, "Finished %ld requests\n", done);
else
printf("..done\n");
***************
*** 1576,1582 ****
/*
* assume proxy-name[:port]
*/
! if (p = index(optarg, ':')) {
*p = '\0';
p++;
proxyport = atoi(p);
--- 1586,1592 ----
/*
* assume proxy-name[:port]
*/
! if ((p = strchr(optarg, ':'))) {
*p = '\0';
p++;
proxyport = atoi(p);
***************
*** 1633,1650 ****
}
if ((heartbeatres) && (requests > 150)) {
! heartbeatres = requests / 10; /* Print line every 10% of requests */
if (heartbeatres < 100)
heartbeatres = 100; /* but never more often than once every 100
* connections. */
}
else
heartbeatres = 0;
#ifdef USE_SSL
SSL_library_init();
if (!(ctx = SSL_CTX_new(SSLv2_client_method()))) {
! fprintf(stderr, "Could not init SSL CTX");
ERR_print_errors_fp(stderr);
exit(1);
}
--- 1643,1663 ----
}
if ((heartbeatres) && (requests > 150)) {
! 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: ");
ERR_print_errors_fp(stderr);
exit(1);
}