Skip to content

Commit

Permalink
mxqd: Use mx_strtobytes() to parse --memory and --max-memory-per-slot…
Browse files Browse the repository at this point in the history
… options
  • Loading branch information
mariux committed Aug 26, 2015
1 parent e9222d8 commit 1cf6306
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,27 @@ int server_init(struct mxq_server *server, int argc, char *argv[])

case 'm':
if (mx_strtoul(optctl.optarg, &memory_total) < 0) {
mx_log_err("Invalid argument supplied for option --memory '%s': %m", optctl.optarg);
exit(1);
unsigned long long int bytes;

if(mx_strtobytes(optctl.optarg, &bytes) < 0) {
mx_log_err("Invalid argument supplied for option --memory '%s': %m", optctl.optarg);
exit(1);
}
memory_total = bytes/1024/1024;
}
if (!memory_total)
memory_total = 2048;
break;

case 'x':
if (mx_strtoul(optctl.optarg, &memory_max) < 0) {
mx_log_err("Invalid argument supplied for option --max-memory-per-slot '%s': %m", optctl.optarg);
exit(1);
unsigned long long int bytes;

if(mx_strtobytes(optctl.optarg, &bytes) < 0) {
mx_log_err("Invalid argument supplied for option --max-memory-per-slot '%s': %m", optctl.optarg);
exit(1);
}
memory_max = bytes/1024/1024;
}
break;

Expand Down

0 comments on commit 1cf6306

Please sign in to comment.