Make the pools array a dynamically allocated array to allow unlimited pools to be added.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
diff --git a/api.c b/api.c
index 42a38c7..ff26e54 100644
--- a/api.c
+++ b/api.c
@@ -1636,10 +1636,7 @@ static void addpool(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
return;
}
- if (add_pool_details(true, url, user, pass) == ADD_POOL_MAXIMUM) {
- strcpy(io_buffer, message(MSG_TOOMANYP, MAX_POOLS, NULL, isjson));
- return;
- }
+ add_pool_details(true, url, user, pass);
ptr = escape_string(url, isjson);
strcpy(io_buffer, message(MSG_ADDPOOL, 0, ptr, isjson));
diff --git a/cgminer.c b/cgminer.c
index 3dc506b..774c5f6 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -190,7 +190,7 @@ unsigned int found_blocks;
unsigned int local_work;
unsigned int total_go, total_ro;
-struct pool *pools[MAX_POOLS];
+struct pool **pools;
static struct pool *currentpool = NULL;
int total_pools;
@@ -395,6 +395,7 @@ static struct pool *add_pool(void)
if (!pool)
quit(1, "Failed to malloc pool in add_pool");
pool->pool_no = pool->prio = total_pools;
+ pools = realloc(pools, sizeof(struct pool *) * (total_pools + 2));
pools[total_pools++] = pool;
if (unlikely(pthread_mutex_init(&pool->pool_lock, NULL)))
quit(1, "Failed to pthread_mutex_init in add_pool");
@@ -4702,13 +4703,10 @@ char *curses_input(const char *query)
}
#endif
-int add_pool_details(bool live, char *url, char *user, char *pass)
+void add_pool_details(bool live, char *url, char *user, char *pass)
{
struct pool *pool;
- if (total_pools == MAX_POOLS)
- return ADD_POOL_MAXIMUM;
-
pool = add_pool();
pool->rpc_url = url;
@@ -4724,8 +4722,6 @@ int add_pool_details(bool live, char *url, char *user, char *pass)
pool->enabled = POOL_ENABLED;
if (live && !pool_active(pool, false))
pool->idle = true;
-
- return ADD_POOL_OK;
}
#ifdef HAVE_CURSES
@@ -4735,10 +4731,6 @@ static bool input_pool(bool live)
bool ret = false;
immedok(logwin, true);
- if (total_pools == MAX_POOLS) {
- wlogprint("Reached maximum number of pools.\n");
- goto out;
- }
wlogprint("Input server details.\n");
url = curses_input("URL");
@@ -4766,7 +4758,8 @@ static bool input_pool(bool live)
if (!pass)
goto out;
- ret = (add_pool_details(live, url, user, pass) == ADD_POOL_OK);
+ add_pool_details(live, url, user, pass);
+ ret = true;
out:
immedok(logwin, false);
diff --git a/miner.h b/miner.h
index 66d7571..024bce6 100644
--- a/miner.h
+++ b/miner.h
@@ -579,13 +579,9 @@ extern void api(int thr_id);
extern struct pool *current_pool(void);
extern int active_pools(void);
-extern int add_pool_details(bool live, char *url, char *user, char *pass);
-
-#define ADD_POOL_MAXIMUM 1
-#define ADD_POOL_OK 0
+extern void add_pool_details(bool live, char *url, char *user, char *pass);
#define MAX_GPUDEVICES 16
-#define MAX_POOLS (32)
#define MIN_INTENSITY -10
#define _MIN_INTENSITY_STR "-10"
@@ -608,7 +604,7 @@ extern struct cgpu_info *cpus;
extern int total_devices;
extern struct cgpu_info **devices;
extern int total_pools;
-extern struct pool *pools[MAX_POOLS];
+extern struct pool **pools;
extern const char *algo_names[];
extern enum sha256_algos opt_algo;
extern struct strategies strategies[];