diff --git a/support/ab.c b/support/ab.c index a4599dc30cc..3206d32c1bc 100644 --- a/support/ab.c +++ b/support/ab.c @@ -244,6 +244,7 @@ struct connection { done; /* Connection closed */ int socknum; + char c_response_code[4]; /* for response code saving */ #ifdef USE_SSL SSL *ssl; #endif @@ -254,6 +255,7 @@ struct data { apr_interval_time_t waittime; /* between request and reading response */ apr_interval_time_t ctime; /* time to connect */ apr_interval_time_t time; /* time for connection */ + char response_code[4]; /* Response code */ }; #define ap_min(a,b) (((a)<(b))?(a):(b)) @@ -1040,7 +1042,7 @@ static void output_results(int sig) exit(1); } fprintf(out, "" "Percentage served" "," "Time in ms" "\n"); - for (i = 0; i < 100; i++) { + for (i = 0; i <= 100; i++) { double t; if (i == 0) t = ap_double_ms(stats[0].time); @@ -1059,17 +1061,18 @@ static void output_results(int sig) perror("Cannot open gnuplot output file"); exit(1); } - fprintf(out, "starttime\tseconds\tctime\tdtime\tttime\twait\n"); + fprintf(out, "starttime\tseconds\tctime\tdtime\tttime\twait\tresponse_code\n"); for (i = 0; i < done; i++) { (void) apr_ctime(tmstring, stats[i].starttime); 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", tmstring, + "\t%" APR_TIME_T_FMT "\t%s\n", tmstring, apr_time_sec(stats[i].starttime), ap_round_ms(stats[i].ctime), ap_round_ms(stats[i].time - stats[i].ctime), ap_round_ms(stats[i].time), - ap_round_ms(stats[i].waittime)); + ap_round_ms(stats[i].waittime), + stats[i].response_code); } fclose(out); } @@ -1364,6 +1367,8 @@ static void close_connection(struct connection * c) s->ctime = ap_max(0, c->connect - c->start); s->time = ap_max(0, c->done - c->start); s->waittime = ap_max(0, c->beginread - c->endwrite); + // Now save the connection response code over to the stats[i] response code. + memcpy(s->response_code, c->c_response_code, 4); if (heartbeatres && !(done % heartbeatres)) { fprintf(stderr, "Completed %d requests\n", done); fflush(stderr); @@ -1563,6 +1568,8 @@ static void read_connection(struct connection * c) else { strcpy(respcode, "500"); } + // save the header. + memcpy(c->c_response_code, respcode, 4); if (respcode[0] != '2') { err_response++;