pgpool2.git / summary / log / commit / refs
commit 0e01d3238bfb887a598fed1999a558cb9349bc64
Author: Muhammad Usama <m.usama@gmail.com>
Date: Thu Apr 07 15:11:49 2016 +0000
removing the limit on the maximum number of items in the black_function_list
and white_function_list lists.
extract_string_tokens in pool_config uses the fixed size malloc on the array to
hold the black_function_list/white_function_list items. This imposes a limit of
maximum items in these lists. The fix is to use realloc to increase the array
size when it gets full.
src/config/pool_config.c | 13 ++++++++++---
src/config/pool_config.l | 13 ++++++++++---
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/src/config/pool_config.c b/src/config/pool_config.c
index ca7a3b556..1ebc25ae6 100644
--- a/src/config/pool_config.c
+++ b/src/config/pool_config.c
@@ -5273,17 +5273,17 @@ int eval_logical(char *str)
* array of pointers in pallocd strings. number of tokens is set to
* n; note that str will be destroyed by strtok().
*/
-#define MAXTOKENS 1024
+#define MAXTOKENS 256
static char **extract_string_tokens(char *str, char *delimi, int *n)
{
char *token;
- static char **tokens;
+ char **tokens;
*n = 0;
tokens = palloc(MAXTOKENS*sizeof(char *));
- for (token = strtok(str, delimi); token != NULL && *n < MAXTOKENS; token = strtok(NULL, delimi))
+ for (token = strtok(str, delimi); token != NULL ; token = strtok(NULL, delimi))
{
tokens[*n] = pstrdup(token);
ereport(DEBUG3,
@@ -5291,7 +5291,14 @@ static char **extract_string_tokens(char *str, char *delimi, int *n)
errdetail("extracting string tokens [token: %s]", tokens[*n])));
(*n)++;
+
+ if ( ((*n) % MAXTOKENS ) == 0)
+ {
+ tokens = repalloc(tokens, (MAXTOKENS * sizeof(char *) * (((*n)/MAXTOKENS) +1) ));
+ }
}
+ /* how about reclaiming the unused space */
+ tokens = repalloc(tokens, (sizeof(char *) * (*n) ));
return tokens;
}
diff --git a/src/config/pool_config.l b/src/config/pool_config.l
index f707c90a0..2152530dd 100644
--- a/src/config/pool_config.l
+++ b/src/config/pool_config.l
@@ -3548,17 +3548,17 @@ int eval_logical(char *str)
* array of pointers in pallocd strings. number of tokens is set to
* n; note that str will be destroyed by strtok().
*/
-#define MAXTOKENS 1024
+#define MAXTOKENS 256
static char **extract_string_tokens(char *str, char *delimi, int *n)
{
char *token;
- static char **tokens;
+ char **tokens;
*n = 0;
tokens = palloc(MAXTOKENS*sizeof(char *));
- for (token = strtok(str, delimi); token != NULL && *n < MAXTOKENS; token = strtok(NULL, delimi))
+ for (token = strtok(str, delimi); token != NULL ; token = strtok(NULL, delimi))
{
tokens[*n] = pstrdup(token);
ereport(DEBUG3,
@@ -3566,7 +3566,14 @@ static char **extract_string_tokens(char *str, char *delimi, int *n)
errdetail("extracting string tokens [token: %s]", tokens[*n])));
(*n)++;
+
+ if ( ((*n) % MAXTOKENS ) == 0)
+ {
+ tokens = repalloc(tokens, (MAXTOKENS * sizeof(char *) * (((*n)/MAXTOKENS) +1) ));
+ }
}
+ /* how about reclaiming the unused space */
+ tokens = repalloc(tokens, (sizeof(char *) * (*n) ));
return tokens;
}
[parent: b5c4ed11ffb1]