Skip to content

Commit

Permalink
fixed some bugs and updated the max-msgs to be flag M
Browse files Browse the repository at this point in the history
  • Loading branch information
ipapapa committed Sep 2, 2015
1 parent 8dfcfef commit 978960a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ To build Dynomite in _debug mode_:
Usage: dynomite [-?hVdDt] [-v verbosity level] [-o output file]
[-c conf file] [-s stats port] [-a stats addr]
[-i stats interval] [-p pid file] [-m mbuf size]
[-M max alloc messages]

Options:
-h, --help : this help
Expand All @@ -47,7 +48,7 @@ To build Dynomite in _debug mode_:
-i, --stats-interval=N : set stats aggregation interval in msec (default: 30000 msec)
-p, --pid-file=S : set pid file (default: off)
-m, --mbuf-size=N : set size of mbuf chunk in bytes (default: 16384 bytes)
-l, --alloc-msgs=N : set max size of allocated messages buffer (default: 2000000)
-M, --max-msgs=N : set max size of allocated messages buffer (default: 2000000)


## Configuration
Expand Down
12 changes: 6 additions & 6 deletions src/dyn_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ static struct option long_options[] = {
{ "stats-addr", required_argument, NULL, 'a' },
{ "pid-file", required_argument, NULL, 'p' },
{ "mbuf-size", required_argument, NULL, 'm' },
{ "alloc_msgs", required_argument, NULL, 'l' },
{ "max_msgs", required_argument, NULL, 'M' },
{ NULL, 0, NULL, 0 }
};

static char short_options[] = "hVtDgv:o:c:s:i:a:p:m:";
static char short_options[] = "hVtDgv:o:c:s:i:a:p:m:M";


static void
dn_show_usage(void)
{
log_stderr(
"Usage: test [-?hVdDt] [-v verbosity level] [-o output file]" CRLF
" [-c conf file] [-m mbuf size] [-l max alloc messages]" CRLF
" [-c conf file] [-m mbuf size] [-M max alloc messages]" CRLF
"");
log_stderr(
"Options:" CRLF
Expand All @@ -76,7 +76,7 @@ dn_show_usage(void)
" -o, --output=S : set logging file (default: %s)" CRLF
" -c, --conf-file=S : set configuration file (default: %s)" CRLF
" -m, --mbuf-size=N : set size of mbuf chunk in bytes (default: %d bytes)" CRLF
" -l, --alloc-msgs=N : set max size of allocated messages buffer (default: %d)" CRLF
" -M, --max-msgs=N : set max size of allocated messages buffer (default: %d)" CRLF
"",
TEST_LOG_DEFAULT, TEST_LOG_DEFAULT, TEST_LOG_DEFAULT,
TEST_LOG_PATH != NULL ? TEST_LOG_PATH : "stderr",
Expand Down Expand Up @@ -177,7 +177,7 @@ test_get_options(int argc, char **argv, struct instance *nci)
nci->mbuf_chunk_size = (size_t)value;
break;

case 'l':
case 'M':
value = dn_atoi(optarg, strlen(optarg));
if (value <= 0) {
log_stderr("test: option -l requires a non-zero number");
Expand All @@ -197,7 +197,7 @@ test_get_options(int argc, char **argv, struct instance *nci)
break;

case 'm':
case 'l':
case 'M':
case 'v':
case 's':
case 'i':
Expand Down
14 changes: 7 additions & 7 deletions src/dynomite.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ static struct option long_options[] = {
{ "stats-addr", required_argument, NULL, 'a' },
{ "pid-file", required_argument, NULL, 'p' },
{ "mbuf-size", required_argument, NULL, 'm' },
{ "alloc-msgs", required_argument, NULL, 'l' },
{ "max-msgs", required_argument, NULL, 'M' },
{ "admin-operation", required_argument, NULL, 'x' },
{ "admin-param", required_argument, NULL, 'y' },
{ NULL, 0, NULL, 0 }
};

static char short_options[] = "hVtdDgv:o:c:s:i:a:p:m:x:y:";
static char short_options[] = "hVtdDgv:o:c:s:i:a:p:m:M:x:y";

static rstatus_t
dn_daemonize(int dump_core)
Expand Down Expand Up @@ -221,7 +221,7 @@ dn_show_usage(void)
"Usage: dynomite [-?hVdDt] [-v verbosity level] [-o output file]" CRLF
" [-c conf file] [-s stats port] [-a stats addr]" CRLF
" [-i stats interval] [-p pid file] [-m mbuf size]" CRLF
" [-l max alloc messages]" CRLF
" [-M max alloc messages]" CRLF
"");
log_stderr(
"Options:" CRLF
Expand All @@ -240,7 +240,7 @@ dn_show_usage(void)
" -i, --stats-interval=N : set stats aggregation interval in msec (default: %d msec)" CRLF
" -p, --pid-file=S : set pid file (default: %s)" CRLF
" -m, --mbuf-size=N : set size of mbuf chunk in bytes (default: %d bytes)" CRLF
" -l, --alloc-msgs=N : set max size of allocated messages buffer (default: %d)" CRLF
" -M, --max-msgs=N : set max size of allocated messages buffer (default: %d)" CRLF
" -x, --admin-operation=N : set size of admin operation (default: %d)" CRLF
"",
DN_LOG_DEFAULT, DN_LOG_MIN, DN_LOG_MAX,
Expand Down Expand Up @@ -436,15 +436,15 @@ dn_get_options(int argc, char **argv, struct instance *nci)
nci->mbuf_chunk_size = (size_t)value;
break;

case 'l':
case 'M':
value = dn_atoi(optarg, strlen(optarg));
if (value <= 0) {
log_stderr("dynomite: option -l requires a non-zero number");
return DN_ERROR;
}

if (value < DN_ALLOC_MSGS_MIN_SIZE || value > DN_ALLOC_MSGS_MAX_SIZE) {
log_stderr("dynomite: allocated messages buffer must be between %zu and"
log_stderr("dynomite: max allocated messages buffer must be between %zu and"
" %zu bytes", DN_ALLOC_MSGS_MIN_SIZE, DN_ALLOC_MSGS_MAX_SIZE);
return DN_ERROR;
}
Expand Down Expand Up @@ -472,7 +472,7 @@ dn_get_options(int argc, char **argv, struct instance *nci)
break;

case 'm':
case 'l':
case 'M':
case 'v':
case 's':
case 'i':
Expand Down

0 comments on commit 978960a

Please sign in to comment.