summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorArno Töll <arno@debian.org>2013-12-23 23:50:09 -1100
committerArno Töll <arno@debian.org>2013-12-23 23:50:09 -1100
commit86d5cc79d9d6750da8771fdb0c9ab22c19b8ad45 (patch)
tree5037da70bf37c0ee93f0ea09f054bdfb278befe0 /support
parent4a336a5b117419c33c29eadd6409c69df78cd586 (diff)
downloadapache2-86d5cc79d9d6750da8771fdb0c9ab22c19b8ad45.tar.gz
Imported Upstream version 2.4.7upstream/2.4.7
Diffstat (limited to 'support')
-rw-r--r--support/ab.c69
-rw-r--r--support/fcgistarter.c5
-rw-r--r--support/htdbm.c2
-rw-r--r--support/rotatelogs.c77
4 files changed, 71 insertions, 82 deletions
diff --git a/support/ab.c b/support/ab.c
index a78e5aee..e2d19b9b 100644
--- a/support/ab.c
+++ b/support/ab.c
@@ -273,6 +273,7 @@ int requests = 1; /* Number of requests to make */
int heartbeatres = 100; /* How often do we say we're alive */
int concurrency = 1; /* Number of multiple requests to make */
int percentile = 1; /* Show percentile served */
+int nolength = 0; /* Accept variable document length */
int confidence = 1; /* Show confidence estimator and warnings */
int tlimit = 0; /* time limit in secs */
int keepalive = 0; /* try and do keepalive connections */
@@ -281,22 +282,20 @@ char servername[1024]; /* name that server reports */
char *hostname; /* host name from URL */
const char *host_field; /* value of "Host:" header field */
const char *path; /* path name */
-char postfile[1024]; /* name of file containing post data */
char *postdata; /* *buffer containing data from postfile */
apr_size_t postlen = 0; /* length of data to be POSTed */
-char content_type[1024];/* content type to put in POST header */
+char *content_type = NULL; /* content type to put in POST header */
const char *cookie, /* optional cookie line */
*auth, /* optional (basic/uuencoded) auhentication */
*hdrs; /* optional arbitrary headers */
apr_port_t port; /* port number */
-char proxyhost[1024]; /* proxy host name */
+char *proxyhost = NULL; /* proxy host name */
int proxyport = 0; /* proxy port */
const char *connecthost;
const char *myhost;
apr_port_t connectport;
const char *gnuplot; /* GNUplot file */
const char *csvperc; /* CSV Percentile file */
-char url[1024];
const char *fullurl;
const char *colonhost;
int isproxy = 0;
@@ -783,7 +782,10 @@ static void output_results(int sig)
#endif
printf("\n");
printf("Document Path: %s\n", path);
- printf("Document Length: %" APR_SIZE_T_FMT " bytes\n", doclen);
+ if (nolength)
+ printf("Document Length: Variable\n");
+ else
+ printf("Document Length: %" APR_SIZE_T_FMT " bytes\n", doclen);
printf("\n");
printf("Concurrency Level: %d\n", concurrency);
printf("Time taken for tests: %.3f seconds\n", timetaken);
@@ -792,7 +794,8 @@ static void output_results(int sig)
if (bad)
printf(" (Connect: %d, Receive: %d, Length: %d, Exceptions: %d)\n",
err_conn, err_recv, err_length, err_except);
- printf("Write errors: %d\n", epipe);
+ if (epipe)
+ printf("Write errors: %d\n", epipe);
if (err_response)
printf("Non-2xx responses: %d\n", err_response);
if (keepalive)
@@ -815,9 +818,9 @@ static void output_results(int sig)
(double) totalread / 1024 / timetaken);
if (send_body) {
printf(" %.2f kb/s sent\n",
- (double) totalposted / timetaken / 1024);
+ (double) totalposted / 1024 / timetaken);
printf(" %.2f kb/s total\n",
- (double) (totalread + totalposted) / timetaken / 1024);
+ (double) (totalread + totalposted) / 1024 / timetaken);
}
}
@@ -965,9 +968,8 @@ static void output_results(int sig)
printf(" min avg max\n");
#define CONF_FMT_STRING "%5" APR_TIME_T_FMT " %5" APR_TIME_T_FMT "%5" APR_TIME_T_FMT "\n"
printf("Connect: " CONF_FMT_STRING, mincon, meancon, maxcon);
- printf("Processing: " CONF_FMT_STRING, mintot - mincon,
- meantot - meancon,
- maxtot - maxcon);
+ printf("Processing: " CONF_FMT_STRING, mind, meand, maxd);
+ printf("Waiting: " CONF_FMT_STRING, minwait, meanwait, maxwait);
printf("Total: " CONF_FMT_STRING, mintot, meantot, maxtot);
#undef CONF_FMT_STRING
}
@@ -1055,9 +1057,14 @@ static void output_html_results(void)
printf("<tr %s><th colspan=2 %s>Document Path:</th>"
"<td colspan=2 %s>%s</td></tr>\n",
trstring, tdstring, tdstring, path);
- printf("<tr %s><th colspan=2 %s>Document Length:</th>"
- "<td colspan=2 %s>%" APR_SIZE_T_FMT " bytes</td></tr>\n",
- trstring, tdstring, tdstring, doclen);
+ if (nolength)
+ printf("<tr %s><th colspan=2 %s>Document Length:</th>"
+ "<td colspan=2 %s>Variable</td></tr>\n",
+ trstring, tdstring, tdstring);
+ else
+ printf("<tr %s><th colspan=2 %s>Document Length:</th>"
+ "<td colspan=2 %s>%" APR_SIZE_T_FMT " bytes</td></tr>\n",
+ trstring, tdstring, tdstring, doclen);
printf("<tr %s><th colspan=2 %s>Concurrency Level:</th>"
"<td colspan=2 %s>%d</td></tr>\n",
trstring, tdstring, tdstring, concurrency);
@@ -1100,16 +1107,16 @@ static void output_html_results(void)
trstring, tdstring, tdstring, (double) done / timetaken);
printf("<tr %s><th colspan=2 %s>Transfer rate:</th>"
"<td colspan=2 %s>%.2f kb/s received</td></tr>\n",
- trstring, tdstring, tdstring, (double) totalread / timetaken);
+ trstring, tdstring, tdstring, (double) totalread / 1024 / timetaken);
if (send_body) {
printf("<tr %s><td colspan=2 %s>&nbsp;</td>"
"<td colspan=2 %s>%.2f kb/s sent</td></tr>\n",
trstring, tdstring, tdstring,
- (double) totalposted / timetaken);
+ (double) totalposted / 1024 / timetaken);
printf("<tr %s><td colspan=2 %s>&nbsp;</td>"
"<td colspan=2 %s>%.2f kb/s total</td></tr>\n",
trstring, tdstring, tdstring,
- (double) (totalread + totalposted) / timetaken);
+ (double) (totalread + totalposted) / 1024 / timetaken);
}
}
{
@@ -1295,7 +1302,7 @@ static void close_connection(struct connection * c)
/* first time here */
doclen = c->bread;
}
- else if (c->bread != doclen) {
+ else if ((c->bread != doclen) && !nolength) {
bad++;
err_length++;
}
@@ -1539,7 +1546,7 @@ static void read_connection(struct connection * c)
/* first time here */
doclen = c->bread;
}
- else if (c->bread != doclen) {
+ else if ((c->bread != doclen) && !nolength) {
bad++;
err_length++;
}
@@ -1666,7 +1673,7 @@ static void test(void)
keepalive ? "Connection: Keep-Alive\r\n" : "",
cookie, auth,
postlen,
- (content_type[0]) ? content_type : "text/plain", hdrs);
+ (content_type != NULL) ? content_type : "text/plain", hdrs);
}
if (snprintf_res >= sizeof(_request)) {
err("Request too long\n");
@@ -1703,7 +1710,7 @@ static void test(void)
exit(1);
}
#endif /* NOT_ASCII */
-
+
if (myhost) {
/* This only needs to be done once */
if ((rv = apr_sockaddr_info_get(&mysa, myhost, APR_UNSPEC, 0, 0, cntxt)) != APR_SUCCESS) {
@@ -1715,7 +1722,7 @@ static void test(void)
}
/* This too */
- if ((rv = apr_sockaddr_info_get(&destsa, connecthost,
+ if ((rv = apr_sockaddr_info_get(&destsa, connecthost,
myhost ? mysa->family : APR_UNSPEC,
connectport, 0, cntxt))
!= APR_SUCCESS) {
@@ -1846,14 +1853,14 @@ static void test(void)
static void copyright(void)
{
if (!use_html) {
- printf("This is ApacheBench, Version %s\n", AP_AB_BASEREVISION " <$Revision: 1430300 $>");
+ printf("This is ApacheBench, Version %s\n", AP_AB_BASEREVISION " <$Revision: 1528965 $>");
printf("Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n");
printf("Licensed to The Apache Software Foundation, http://www.apache.org/\n");
printf("\n");
}
else {
printf("<p>\n");
- printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i><br>\n", AP_AB_BASEREVISION, "$Revision: 1430300 $");
+ printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i><br>\n", AP_AB_BASEREVISION, "$Revision: 1528965 $");
printf(" Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n");
printf(" Licensed to The Apache Software Foundation, http://www.apache.org/<br>\n");
printf("</p>\n<p>\n");
@@ -1903,6 +1910,7 @@ static void usage(const char *progname)
fprintf(stderr, " -d Do not show percentiles served table.\n");
fprintf(stderr, " -S Do not show confidence estimators and warnings.\n");
fprintf(stderr, " -q Do not show progress when doing more than 150 requests\n");
+ fprintf(stderr, " -l Accept variable document length (use this for dynamic pages)\n");
fprintf(stderr, " -g filename Output collected data to gnuplot format file.\n");
fprintf(stderr, " -e filename Output CSV file with percentages served\n");
fprintf(stderr, " -r Don't exit on socket receive errors.\n");
@@ -1922,7 +1930,7 @@ static void usage(const char *progname)
#endif
fprintf(stderr, " -Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)\n");
- fprintf(stderr, " -f protocol Specify SSL/TLS protocol\n");
+ fprintf(stderr, " -f protocol Specify SSL/TLS protocol\n");
fprintf(stderr, " (" SSL2_HELP_MSG "SSL3, TLS1" TLS1_X_HELP_MSG " or ALL)\n");
#endif
exit(EINVAL);
@@ -2059,7 +2067,7 @@ int main(int argc, const char * const argv[])
tdstring = "bgcolor=white";
cookie = "";
auth = "";
- proxyhost[0] = '\0';
+ proxyhost = "";
hdrs = "";
apr_app_initialize(&argc, &argv, NULL);
@@ -2087,7 +2095,7 @@ int main(int argc, const char * const argv[])
myhost = NULL; /* 0.0.0.0 or :: */
apr_getopt_init(&opt, cntxt, argc, argv);
- while ((status = apr_getopt(opt, "n:c:t:s:b:T:p:u:v:rkVhwix:y:z:C:H:P:A:g:X:de:SqB:"
+ while ((status = apr_getopt(opt, "n:c:t:s:b:T:p:u:v:lrkVhwix:y:z:C:H:P:A:g:X:de:SqB:"
#ifdef USE_SSL
"Z:f:"
#endif
@@ -2149,6 +2157,9 @@ int main(int argc, const char * const argv[])
method = PUT;
send_body = 1;
break;
+ case 'l':
+ nolength = 1;
+ break;
case 'r':
recverrok = 1;
break;
@@ -2161,7 +2172,7 @@ int main(int argc, const char * const argv[])
* something */
break;
case 'T':
- strcpy(content_type, opt_arg);
+ content_type = apr_pstrdup(cntxt, opt_arg);
break;
case 'C':
cookie = apr_pstrcat(cntxt, "Cookie: ", opt_arg, "\r\n", NULL);
@@ -2232,7 +2243,7 @@ int main(int argc, const char * const argv[])
p++;
proxyport = atoi(p);
}
- strcpy(proxyhost, opt_arg);
+ proxyhost = apr_pstrdup(cntxt, opt_arg);
isproxy = 1;
}
break;
diff --git a/support/fcgistarter.c b/support/fcgistarter.c
index 2e2c3e56..9cfda51a 100644
--- a/support/fcgistarter.c
+++ b/support/fcgistarter.c
@@ -133,6 +133,11 @@ int main(int argc, const char * const argv[])
exit_error(rv, "apr_socket_create");
}
+ rv = apr_socket_opt_set(skt, APR_SO_REUSEADDR, 1);
+ if (rv) {
+ exit_error(rv, "apr_socket_opt_set(APR_SO_REUSEADDR)");
+ }
+
rv = apr_socket_bind(skt, skaddr);
if (rv) {
exit_error(rv, "apr_socket_bind");
diff --git a/support/htdbm.c b/support/htdbm.c
index 1452d7a0..1cd0591f 100644
--- a/support/htdbm.c
+++ b/support/htdbm.c
@@ -337,7 +337,7 @@ int main(int argc, const char * const argv[])
if (rv != APR_SUCCESS)
exit(ERR_SYNTAX);
- while ((rv = apr_getopt(state, "cnmspdBbDivxlC:T:", &opt, &opt_arg)) == APR_SUCCESS) {
+ while ((rv = apr_getopt(state, "cnmspdBbtivxlC:T:", &opt, &opt_arg)) == APR_SUCCESS) {
switch (opt) {
case 'c':
h->create = 1;
diff --git a/support/rotatelogs.c b/support/rotatelogs.c
index 3f32f3ca..cf1eac1e 100644
--- a/support/rotatelogs.c
+++ b/support/rotatelogs.c
@@ -14,31 +14,6 @@
* limitations under the License.
*/
-/*
- * Simple program to rotate Apache logs without having to kill the server.
- *
- * Contributed by Ben Laurie <ben algroup.co.uk>
- *
- * 12 Mar 1996
- *
- * Ported to APR by Mladen Turk <mturk mappingsoft.com>
- *
- * 23 Sep 2001
- *
- * -l option added 2004-06-11
- *
- * -l causes the use of local time rather than GMT as the base for the
- * interval. NB: Using -l in an environment which changes the GMT offset
- * (such as for BST or DST) can lead to unpredictable results!
- *
- * -f option added Feb, 2008. This causes rotatelog to open/create
- * the logfile as soon as it's started, not as soon as it sees
- * data.
- *
- * -v option added Feb, 2008. Verbose output of command line parsing.
- */
-
-
#include "apr.h"
#include "apr_lib.h"
#include "apr_strings.h"
@@ -62,17 +37,13 @@
#define BUFSIZE 65536
#define ERRMSGSZ 256
-#ifndef MAX_PATH
-#define MAX_PATH 1024
-#endif
-
#define ROTATE_NONE 0
#define ROTATE_NEW 1
#define ROTATE_TIME 2
#define ROTATE_SIZE 3
#define ROTATE_FORCE 4
-static const char *ROTATE_REASONS[] = {
+static const char *const ROTATE_REASONS[] = {
"None",
"Open a new file",
"Time interval expired",
@@ -109,7 +80,7 @@ typedef struct rotate_status rotate_status_t;
struct logfile {
apr_pool_t *pool;
apr_file_t *fd;
- char name[MAX_PATH];
+ char name[APR_PATH_MAX];
};
struct rotate_status {
@@ -299,7 +270,6 @@ static void post_rotate(apr_pool_t *pool, struct logfile *newlog,
}
rv = apr_file_link(newlog->name, config->linkfile);
if (rv != APR_SUCCESS) {
- char error[120];
apr_strerror(rv, error, sizeof error);
fprintf(stderr, "Error linking file %s to %s (%s)\n",
newlog->name, config->linkfile, error);
@@ -358,6 +328,24 @@ static void post_rotate(apr_pool_t *pool, struct logfile *newlog,
}
}
+/* After a error, truncate the current file and write out an error
+ * message, which must be contained in status->errbuf. The process is
+ * terminated on failure. */
+static void truncate_and_write_error(rotate_status_t *status)
+{
+ apr_size_t buflen = strlen(status->errbuf);
+
+ if (apr_file_trunc(status->current.fd, 0) != APR_SUCCESS) {
+ fprintf(stderr, "Error truncating the file %s\n", status->current.name);
+ exit(2);
+ }
+ if (apr_file_write_full(status->current.fd, status->errbuf, buflen, NULL) != APR_SUCCESS) {
+ fprintf(stderr, "Error writing error (%s) to the file %s\n",
+ status->errbuf, status->current.name);
+ exit(2);
+ }
+}
+
/*
* Open a new log file, and if successful
* also close the old one.
@@ -447,7 +435,6 @@ static void doRotate(rotate_config_t *config, rotate_status_t *status)
}
else {
char error[120];
- apr_size_t nWrite;
apr_strerror(rv, error, sizeof error);
@@ -468,16 +455,8 @@ static void doRotate(rotate_config_t *config, rotate_status_t *status)
"Resetting log file due to error opening "
"new log file, %10d messages lost: %-25.25s\n",
status->nMessCount, error);
- nWrite = strlen(status->errbuf);
- if (apr_file_trunc(status->current.fd, 0) != APR_SUCCESS) {
- fprintf(stderr, "Error truncating the file %s\n", status->current.name);
- exit(2);
- }
- if (apr_file_write_full(status->current.fd, status->errbuf, nWrite, NULL) != APR_SUCCESS) {
- fprintf(stderr, "Error writing to the file %s\n", status->current.name);
- exit(2);
- }
+ truncate_and_write_error(status);
}
status->nMessCount = 0;
@@ -718,25 +697,19 @@ int main (int argc, const char * const argv[])
nWrite = nRead;
rv = apr_file_write_full(status.current.fd, buf, nWrite, &nWrite);
if (nWrite != nRead) {
- char strerrbuf[120];
apr_off_t cur_offset;
cur_offset = 0;
if (apr_file_seek(status.current.fd, APR_CUR, &cur_offset) != APR_SUCCESS) {
cur_offset = -1;
}
- apr_strerror(rv, strerrbuf, sizeof strerrbuf);
status.nMessCount++;
apr_snprintf(status.errbuf, sizeof status.errbuf,
"Error %d writing to log file at offset %" APR_OFF_T_FMT ". "
- "%10d messages lost (%s)\n",
- rv, cur_offset, status.nMessCount, strerrbuf);
- nWrite = strlen(status.errbuf);
- apr_file_trunc(status.current.fd, 0);
- if (apr_file_write_full(status.current.fd, status.errbuf, nWrite, NULL) != APR_SUCCESS) {
- fprintf(stderr, "Error writing to the file %s\n", status.current.name);
- exit(2);
- }
+ "%10d messages lost (%pm)\n",
+ rv, cur_offset, status.nMessCount, &rv);
+
+ truncate_and_write_error(&status);
}
else {
status.nMessCount++;