You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2012/02/26 21:38:04 UTC
git commit: Add a -max_connect_failures option to http_load
Updated Branches:
refs/heads/master 89808dd4a -> dd93d7271
Add a -max_connect_failures option to http_load
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/dd93d727
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/dd93d727
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/dd93d727
Branch: refs/heads/master
Commit: dd93d727122b1577c3dd5856ecadb3b30f73d218
Parents: 89808dd
Author: Leif Hedstrom <zw...@apache.org>
Authored: Sun Feb 26 13:37:58 2012 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Sun Feb 26 13:37:58 2012 -0700
----------------------------------------------------------------------
tools/http_load/http_load.c | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dd93d727/tools/http_load/http_load.c
----------------------------------------------------------------------
diff --git a/tools/http_load/http_load.c b/tools/http_load/http_load.c
index 304e2f4..063a1fa 100644
--- a/tools/http_load/http_load.c
+++ b/tools/http_load/http_load.c
@@ -273,6 +273,7 @@ static unsigned int unique_id_counter;
static int unique_id = 0;
static int socket_pool;
static int epfd;
+static int max_connect_failures = 0;
static struct timeval start_at;
static int fetches_started, connects_completed, responses_completed, fetches_completed;
@@ -445,7 +446,13 @@ main(int argc, char **argv)
cookie = argv[++argn];
else if (strncmp(argv[argn], "-ignore_bytes", strlen(argv[argn])) == 0)
ignore_bytes = 1;
- else if (strncmp(argv[argn], "-header", strlen(argv[argn])) == 0 && argn + 1 < argc) {
+ else if (strncmp(argv[argn], "-max_connect_failures", strlen(argv[argn])) == 0) {
+ max_connect_failures = atoi(argv[++argn]);
+ if (max_connect_failures < 1) {
+ (void) fprintf(stderr, "%s: max_connection failures should be 1 or higher\n", argv0);
+ exit(1);
+ }
+ } else if (strncmp(argv[argn], "-header", strlen(argv[argn])) == 0 && argn + 1 < argc) {
if (extra_headers) {
strcat(extra_headers, "\r\n");
strcat(extra_headers, argv[++argn]);
@@ -628,14 +635,18 @@ static void
usage(void)
{
(void) fprintf(stderr,
- "usage: %s [-checksum] [-throttle] [-sequential] [-proxy host:port] [-verbose] [-timeout secs] [-sip sip_file] [-agent user_agent] [-cookie http_cookie] [-accept_gzip] [-http_version version_str] [-keep_alive num_reqs_per_conn] [-unique_id] [-ignore_bytes] [ [-header str] ... ]\n",
+ "usage: %s [-checksum] [-throttle] [-sequential] [-proxy host:port]\n"
+ " [-verbose] [-timeout secs] [-sip sip_file] [-agent user_agent]\n"
+ " [-cookie http_cookie] [-accept_gzip] [-http_version version_str]\n"
+ " [-keep_alive num_reqs_per_conn] [-unique_id]\n"
+ " [-max_connect_failures N] [-ignore_bytes] [ [-header str] ... ]\n",
argv0);
#ifdef USE_SSL
- (void) fprintf(stderr, " [-cipher str]\n");
+ (void) fprintf(stderr, " [-cipher str]\n");
#endif /* USE_SSL */
- (void) fprintf(stderr, " -parallel N | -rate N [-jitter]\n");
- (void) fprintf(stderr, " -fetches N | -seconds N\n");
- (void) fprintf(stderr, " url_file\n");
+ (void) fprintf(stderr, " -parallel N | -rate N [-jitter]\n");
+ (void) fprintf(stderr, " -fetches N | -seconds N\n");
+ (void) fprintf(stderr, " url_file\n");
(void) fprintf(stderr, "One start specifier, either -parallel or -rate, is required.\n");
(void) fprintf(stderr, "One end specifier, either -fetches or -seconds, is required.\n");
exit(1);
@@ -1161,6 +1172,7 @@ start_socket(int url_num, int cnum, struct timeval *nowP)
static void
handle_connect(int cnum, struct timeval *nowP, int double_check)
{
+ static int connect_failures = 0;
int url_num;
int r;
#ifdef linux
@@ -1178,6 +1190,8 @@ handle_connect(int cnum, struct timeval *nowP, int double_check)
int err, errlen;
if (connect(connections[cnum].conn_fd, (struct sockaddr *) &connections[cnum].sa, connections[cnum].sa_len) < 0) {
+ if (max_connect_failures && (++connect_failures > max_connect_failures))
+ exit(0);
switch (errno) {
case EISCONN:
/* Ok! */