From 75bf36ff0e46d74a8549369da0d7ab66feed2d6b Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 22 Jul 2011 13:58:06 +1000 Subject: [PATCH] Allow the pool strategy to be modified on the fly. --- main.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index b052ef92..ec925d88 100644 --- a/main.c +++ b/main.c @@ -106,6 +106,8 @@ enum pool_strategy { POOL_LOADBALANCE, }; +#define TOP_STRATEGY (POOL_LOADBALANCE) + struct strategies { const char *s; } strategies[] = { @@ -1432,7 +1434,10 @@ updated: wattroff(logwin, A_BOLD | A_DIM); } retry: - wprintw(logwin, "\nCurrent pool management strategy: %s\n", strategies[pool_strategy]); + wprintw(logwin, "\nCurrent pool management strategy: %s\n", + strategies[pool_strategy]); + if (pool_strategy == POOL_ROTATE) + wprintw(logwin, "Set to rotate every %d minutes\n", opt_rotate_period); wprintw(logwin, "[A]dd pool [R]emove pool [D]isable pool [E]nable pool\n"); wprintw(logwin, "[C]hange management strategy [S]witch pool\n"); wprintw(logwin, "Or press any other key to continue\n"); @@ -1479,8 +1484,29 @@ retry: if (pool->prio < current_pool()->prio) switch_pools(pool); goto updated; + } else if (!strncasecmp(&input, "c", 1)) { + for (i = 0; i <= TOP_STRATEGY; i++) + wprintw(logwin, "%d: %s\n", i, strategies[i]); + selected = curses_int("Select strategy number type"); + if (selected < 0 || selected > TOP_STRATEGY) { + wprintw(logwin, "Invalid selection"); + goto retry; + } + if (selected == POOL_ROTATE) { + opt_rotate_period = curses_int("Select interval in minutes"); + + if (opt_rotate_period < 0 || opt_rotate_period > 9999) { + opt_rotate_period = 0; + wprintw(logwin, "Invalid selection"); + goto retry; + } + } + pool_strategy = selected; + switch_pools(NULL); + goto updated; } + clear_logwin(); opt_loginput = false; }