Skip to content

mctpd: Make timeout and bus owner configs configurable #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/mctpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3074,9 +3074,10 @@ static int setup_testing(ctx *ctx) {

static void print_usage(ctx *ctx)
{
fprintf(stderr, "mctpd [-v] [-N]\n");
fprintf(stderr, "mctpd [-v] [-N] [-t usecs]\n");
fprintf(stderr, " -v verbose\n");
fprintf(stderr, " -N testing mode. Not safe for production\n");
fprintf(stderr, " -t timeout in usecs\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timeout for what? This may need to be a little more descriptive.

And why microseconds here? milliseconds may be easier to deal with.

}

static int parse_args(ctx *ctx, int argc, char **argv)
Expand All @@ -3085,12 +3086,16 @@ static int parse_args(ctx *ctx, int argc, char **argv)
{ .name = "help", .has_arg = no_argument, .val = 'h' },
{ .name = "verbose", .has_arg = no_argument, .val = 'v' },
{ .name = "testing", .has_arg = no_argument, .val = 'N' },
{ .name = "timeout", .has_arg = required_argument, .val = 't' },
{ 0 },
};
int c;

// default values
ctx->mctp_timeout = 250000; // 250ms

for (;;) {
c = getopt_long(argc, argv, "+hvN", options, NULL);
c = getopt_long(argc, argv, "+hvNt:", options, NULL);
if (c == -1)
break;

Expand All @@ -3101,6 +3106,13 @@ static int parse_args(ctx *ctx, int argc, char **argv)
case 'v':
ctx->verbose = true;
break;
case 't':
ctx->mctp_timeout = strtoull(optarg, NULL, 10);
if (ctx->mctp_timeout == 0) {
warnx("Timeout must be a non-zero u64");
return errno;
}
break;
case 'h':
default:
print_usage(ctx);
Expand Down Expand Up @@ -3138,7 +3150,6 @@ static int setup_config(ctx *ctx)
{
int rc;
// TODO: this will go in a config file or arguments.
ctx->mctp_timeout = 250000; // 250ms
ctx->bus_owner = true;
rc = fill_uuid(ctx);
if (rc < 0)
Expand Down