Skip to content

Commit

Permalink
mxqd: Prefix argument variables with arg_
Browse files Browse the repository at this point in the history
  • Loading branch information
mariux committed Oct 23, 2015
1 parent a83d32d commit e8bea63
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ int server_init(struct mxq_server *server, int argc, char *argv[])
char arg_recoveronly = 0;
char *str_bootid;
int opt;
unsigned long threads_total = 0;
unsigned long memory_total = 2048;
unsigned long memory_max = 0;
unsigned long arg_threads_total = 0;
unsigned long arg_memory_total = 2048;
unsigned long arg_memory_max = 0;
int i;
struct proc_pid_stat pps = {0};

Expand Down Expand Up @@ -361,35 +361,35 @@ int server_init(struct mxq_server *server, int argc, char *argv[])
exit(EX_USAGE);

case 'j':
if (mx_strtoul(optctl.optarg, &threads_total) < 0) {
if (mx_strtoul(optctl.optarg, &arg_threads_total) < 0) {
mx_log_err("Invalid argument supplied for option --slots '%s': %m", optctl.optarg);
exit(1);
}
break;

case 'm':
if (mx_strtoul(optctl.optarg, &memory_total) < 0) {
if (mx_strtoul(optctl.optarg, &arg_memory_total) < 0) {
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;
arg_memory_total = bytes/1024/1024;
}
if (!memory_total)
memory_total = 2048;
if (!arg_memory_total)
arg_memory_total = 2048;
break;

case 'x':
if (mx_strtoul(optctl.optarg, &memory_max) < 0) {
if (mx_strtoul(optctl.optarg, &arg_memory_max) < 0) {
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;
arg_memory_max = bytes/1024/1024;
}
break;

Expand Down Expand Up @@ -508,14 +508,14 @@ int server_init(struct mxq_server *server, int argc, char *argv[])

mx_asprintf_forever(&server->host_id, "%s-%llx-%x", server->boot_id, server->starttime, getpid());

server->slots = threads_total;
server->slots = arg_threads_total;
res = cpuset_init(server);
if (res < 0) {
mx_log_err("MAIN: cpuset_init() failed. exiting.");
exit(1);
}
server->memory_total = memory_total;
server->memory_max_per_slot = memory_max;
server->memory_total = arg_memory_total;
server->memory_max_per_slot = arg_memory_max;
server->memory_avg_per_slot = (long double)server->memory_total / (long double)server->slots;

if (server->memory_max_per_slot < server->memory_avg_per_slot)
Expand All @@ -524,7 +524,6 @@ int server_init(struct mxq_server *server, int argc, char *argv[])
if (server->memory_max_per_slot > server->memory_total)
server->memory_max_per_slot = server->memory_total;


return 1;
}

Expand Down

0 comments on commit e8bea63

Please sign in to comment.