Commit 1ea1083f authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(longopts): Added --priority and --weight.

(main): Handle the new options.
parent ee19a359
......@@ -509,6 +509,8 @@ static struct option longopts[] = {
{"time-abort", 0, 0, 'a'},
{"time-limit", 0, 0, 'l'},
{"write-only", 0, 0, 'w'},
{"priority", 0, 0, 'p'},
{"weight", 0, 0, 'W'},
{ 0, 0, 0, 0 }
};
......@@ -532,10 +534,14 @@ main(int argc,
int do_abort_time = 0;
int verbose = 0;
/* Alter scheduling? */
int priority = -1;
int weight = -1;
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
fail("signal");
while ((optc = getopt_long(argc, argv, "wvalp",
while ((optc = getopt_long(argc, argv, "W:wvalp:",
longopts, (int *) 0)) != EOF)
{
switch (optc)
......@@ -560,6 +566,14 @@ main(int argc,
do_write_only = 1;
break;
case 'W':
weight = atoi(optarg);
break;
case 'p':
priority = atoi(optarg);
break;
case '?':
fail("usage");
}
......@@ -568,6 +582,9 @@ main(int argc,
if (optind + 2 != argc)
fail("usage");
if ((priority == -1) + (weight == -1) == 1)
fail("usage");
server = tcp_connect(argv[optind], argv[optind + 1]);
puts("connected");
if (write(server, "A3Hfoo\n", 7) != 7)
......@@ -588,6 +605,27 @@ main(int argc,
puts("handshake OK");
if (priority != -1)
{
sprintf(buf, "1 119 0 %d %d\n", priority, weight);
if (write(server, buf, strlen(buf)) != (ssize_t)strlen(buf))
fail("set-scheduling write");
if ((rv = read(server, buf, sizeof(buf))) < 0)
fail("set-scheduling read");
if (rv == 0)
{
fprintf(stderr, "unexpected EOF from server after set-schedule\n");
exit(1);
}
if (rv != 3 || strncmp(buf, "=1\n", 3) != 0)
{
fprintf(stderr, "Got bad reply ``%.*s'' to set-schedule\n",
(int)rv, buf);
exit(1);
}
puts("set-schedule ok");
}
if ((sys = oop_sys_new()) == NULL)
fail("oop_sys_new");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment