Skip to content

Commit

Permalink
Explicitely check for positive thread value and set default if not
Browse files Browse the repository at this point in the history
  • Loading branch information
badboy committed Apr 7, 2017
1 parent ed3ad26 commit d9fc7a7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "socket.h"
#include "array.h"

#define DEFAULT_THREAD 4
#define DEFAULT_BUFSIZE 16384
#define MIN_BUFSIZE 64
#define TMP_CONFIG_FILE "tmp-corvus.conf"
Expand Down Expand Up @@ -47,7 +48,7 @@ void config_init()
config.bind = 12345;
config.node = cv_calloc(1, sizeof(struct node_conf));
config.node->refcount = 1;
config.thread = 4;
config.thread = DEFAULT_THREAD;
config.loglevel = INFO;
config.syslog = 0;
config.stats = false;
Expand Down Expand Up @@ -196,8 +197,12 @@ int config_add(char *name, char *value)
config.readmasterslave = config.readslave = false;
}
} else if (strcmp(name, "thread") == 0) {
return parse_int(value, &config.thread);
if (config.thread <= 0) config.thread = 4;
TRY_PARSE_INT();
if (val <= 0) {
config.thread = DEFAULT_THREAD;
} else {
config.thread = val;
}
} else if (strcmp(name, "bufsize") == 0) {
TRY_PARSE_INT();
if (val <= 0) {
Expand Down

0 comments on commit d9fc7a7

Please sign in to comment.