summaryrefslogtreecommitdiffstats
path: root/glusterfsd
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@zresearch.com>2009-03-31 10:56:10 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-04-01 13:20:06 +0530
commitdb365c30d07f5faae4197e37148f64e75b54a7ec (patch)
tree5ae79870edcebfabe588bdc91f71910d45f72fa8 /glusterfsd
parentaa63a122433d51e89148af27dab98cf68846dab4 (diff)
Enable glusterfs client to exit after a configured number of failed connects \ while fetching volume specification file from server
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'glusterfsd')
-rw-r--r--glusterfsd/src/fetch-spec.c6
-rw-r--r--glusterfsd/src/glusterfsd.c16
-rw-r--r--glusterfsd/src/glusterfsd.h1
3 files changed, 23 insertions, 0 deletions
diff --git a/glusterfsd/src/fetch-spec.c b/glusterfsd/src/fetch-spec.c
index f914a416d..3e9712d8d 100644
--- a/glusterfsd/src/fetch-spec.c
+++ b/glusterfsd/src/fetch-spec.c
@@ -71,6 +71,7 @@ fetch_notify (xlator_t *this_xl, int event, void *data, ...)
{
int ret = 0;
call_frame_t *frame = NULL;
+ static int failed_connects = 0;
switch (event)
{
@@ -85,6 +86,11 @@ fetch_notify (xlator_t *this_xl, int event, void *data, ...)
0);
break;
case GF_EVENT_CHILD_DOWN:
+ failed_connects++;
+ if (failed_connects
+ >= this_xl->ctx->cmd_args.max_connect_attempts) {
+ exit (1);
+ }
break;
default:
ret = default_notify (this_xl, event, data);
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index 37eefa01b..d4ac16a30 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -85,6 +85,10 @@ static struct argp_option gf_options[] = {
{"volfile-server", ARGP_VOLFILE_SERVER_KEY, "SERVER", 0,
"Server to get the volume file from. This option overrides "
"--volfile option"},
+ {"volfile-max-fetch-attempts", ARGP_VOLFILE_MAX_FETCH_ATTEMPTS,
+ "MAX-ATTEMPTS", 0, "Maximum number of connect attempts to server. "
+ "This option should be provided with --volfile-server option"
+ "[default: 1]"},
{"volfile", ARGP_VOLUME_FILE_KEY, "VOLFILE", 0,
"File to use as VOLUME_FILE [default: "DEFAULT_CLIENT_VOLUME_FILE" or "
DEFAULT_SERVER_VOLUME_FILE"]"},
@@ -659,7 +663,19 @@ parse_opts (int key, char *arg, struct argp_state *state)
case ARGP_VOLFILE_SERVER_KEY:
cmd_args->volfile_server = strdup (arg);
break;
+
+ case ARGP_VOLFILE_MAX_FETCH_ATTEMPTS:
+ n = 0;
+ if (gf_string2uint_base10 (arg, &n) == 0) {
+ cmd_args->max_connect_attempts = n;
+ break;
+ }
+
+ argp_failure (state, -1, 0,
+ "Invalid limit on connect attempts %s", arg);
+ break;
+
case ARGP_VOLUME_FILE_KEY:
cmd_args->volume_file = strdup (arg);
break;
diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h
index 0d6423ab4..e06526b06 100644
--- a/glusterfsd/src/glusterfsd.h
+++ b/glusterfsd/src/glusterfsd.h
@@ -71,6 +71,7 @@ enum argp_option_keys {
#endif /* DARWIN */
ARGP_VOLFILE_ID_KEY = 143,
ARGP_VOLFILE_CHECK_KEY = 144,
+ ARGP_VOLFILE_MAX_FETCH_ATTEMPTS = 145,
};
/* Moved here from fetch-spec.h */