From 1cf63064ad814f838125cc68233d452e343f416a Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Wed, 26 Aug 2015 18:20:22 +0200 Subject: [PATCH] mxqd: Use mx_strtobytes() to parse --memory and --max-memory-per-slot options --- mxqd.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mxqd.c b/mxqd.c index b5e6697..8bd485c 100644 --- a/mxqd.c +++ b/mxqd.c @@ -290,8 +290,13 @@ 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; @@ -299,8 +304,13 @@ int server_init(struct mxq_server *server, int argc, char *argv[]) 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;