diff options
author | Ben Pfaff <blp@nicira.com> | 2009-12-17 13:46:16 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2010-01-04 09:47:01 -0800 |
commit | a85c0bbcfd19fcd88ee9966a86dd83107dfd6603 (patch) | |
tree | d16164fc8a5ca6fcdbb9546c5e1e21c27bd33d9c /tests/test-reconnect.c | |
parent | b8781ff08d9981258e75789c6f4ed18a56991577 (diff) | |
download | openvswitch-a85c0bbcfd19fcd88ee9966a86dd83107dfd6603.tar.gz |
reconnect: Add connection attempt limiting feature.
Sometimes it is useful to limit the number of connection attempts, either
from policy or because it is not possible to reconnect at all (e.g. because
a connection was accepted from a listening socket instead of made with
connect()). This commit adds that feature.
Diffstat (limited to 'tests/test-reconnect.c')
-rw-r--r-- | tests/test-reconnect.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test-reconnect.c b/tests/test-reconnect.c index a8784fc88..8441fadd3 100644 --- a/tests/test-reconnect.c +++ b/tests/test-reconnect.c @@ -40,6 +40,7 @@ int main(void) { struct reconnect_stats prev; + unsigned int old_max_tries; int old_time; char line[128]; @@ -49,6 +50,7 @@ main(void) reconnect_get_stats(reconnect, now, &prev); printf("### t=%d ###\n", now); old_time = now; + old_max_tries = reconnect_get_max_tries(reconnect); while (fgets(line, sizeof line, stdin)) { struct reconnect_stats cur; struct svec args; @@ -74,6 +76,10 @@ main(void) reconnect_get_stats(reconnect, now, &cur); diff_stats(&prev, &cur); prev = cur; + if (reconnect_get_max_tries(reconnect) != old_max_tries) { + old_max_tries = reconnect_get_max_tries(reconnect); + printf(" %u tries left\n", old_max_tries); + } } return 0; @@ -191,6 +197,12 @@ do_timeout(int argc UNUSED, char *argv[] UNUSED) } static void +do_set_max_tries(int argc UNUSED, char *argv[]) +{ + reconnect_set_max_tries(reconnect, atoi(argv[1])); +} + +static void diff_stats(const struct reconnect_stats *old, const struct reconnect_stats *new) { @@ -235,6 +247,7 @@ static const struct command commands[] = { { "run", 0, 1, do_run }, { "advance", 1, 1, do_advance }, { "timeout", 0, 0, do_timeout }, + { "set-max-tries", 1, 1, do_set_max_tries }, { NULL, 0, 0, NULL }, }; |