Skip to content
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

Cleaning the FLUX module code #129

Merged
merged 3 commits into from
Jan 2, 2025
Merged
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
Prev Previous commit
Remove unused variable
Signed-off-by: Chen Wang <[email protected]>
wangvsa committed Dec 30, 2024
commit 2e499caac229f09c131520aca1c09f6a962f6608
18 changes: 4 additions & 14 deletions src/dyad/modules/dyad.c
Original file line number Diff line number Diff line change
@@ -309,7 +309,6 @@ typedef struct opt_parse_out opt_parse_out_t;

int opt_parse (opt_parse_out_t *restrict opt,
const unsigned broker_rank,
dyad_dtl_mode_t *restrict dtl_mode,
int argc,
char **restrict argv)
{
@@ -319,7 +318,6 @@ int opt_parse (opt_parse_out_t *restrict opt,
sprintf (log_file_name, "dyad_mod_%u.out", broker_rank);
sprintf (err_file_name, "dyad_mod_%d.err", broker_rank);
#endif // DYAD_LOGGER_NO_LOG
*dtl_mode = DYAD_DTL_END;

int rc = DYAD_RC_OK;
char *prod_managed_path = NULL;
@@ -335,15 +333,15 @@ int opt_parse (opt_parse_out_t *restrict opt,
// argv[0] to be the executable name, so it starts
// checking from optind = 1.
// since Flux module argv doesn't contain the executable
// name as its first argument, we need to create a dummy
// name in its first argument, we need to create a dummy
// _argc and _argv here for getopt() to work properly.
extern int optind;
optind = 1;
int _argc = argc + 1;
char **_argv = malloc (sizeof (char *) * _argc);
_argv[0] = NULL;
for (int i = 1; i < _argc; i++) {
// we will reuse the same same string in argv[].
// we will reuse the same string in argv[].
_argv[i] = argv[i - 1];
}

@@ -372,10 +370,7 @@ int opt_parse (opt_parse_out_t *restrict opt,
// mode as the option, then skip reinitializing
DYAD_LOG_STDERR ("DYAD_MOD: DTL 'mode' option -m with value `%s'\n", optarg);
opt->dtl_mode = optarg;
if (strcmp ("UCX", optarg) == 0)
*dtl_mode = DYAD_DTL_UCX;
else if (strcmp ("FLUX_RPC", optarg) == 0)
*dtl_mode = DYAD_DTL_FLUX_RPC;
// TODO: check if the user specified dtl_mode is valid.
break;
case 'i':
#ifndef DYAD_LOGGER_NO_LOG
@@ -404,10 +399,6 @@ int opt_parse (opt_parse_out_t *restrict opt,
DYAD_LOG_STDERR_REDIRECT (err_file_name);
#endif // DYAD_LOGGER_NO_LOG

if (*dtl_mode == DYAD_DTL_END) {
opt->dtl_mode = NULL;
}

// Retrive the remaining command line argument (not options).
// it is expected to be the producer managed directory
while (optind < _argc) {
@@ -487,7 +478,6 @@ DYAD_DLL_EXPORTED int mod_main (flux_t *h, int argc, char **argv)
DYAD_LOGGER_INIT ();
DYAD_LOG_STDOUT ("DYAD_MOD: Loading mod_main\n");
dyad_mod_ctx_t *mod_ctx = NULL;
dyad_dtl_mode_t dtl_mode = DYAD_DTL_DEFAULT;

if (!h) {
DYAD_LOG_STDERR ("DYAD_MOD: Failed to get flux handle\n");
@@ -507,7 +497,7 @@ DYAD_DLL_EXPORTED int mod_main (flux_t *h, int argc, char **argv)
opt_parse_out_t opt = {NULL, NULL, false, false};
DYAD_LOG_STDOUT ("DYAD_MOD: Parsing command line options\n");

if (DYAD_IS_ERROR (opt_parse (&opt, broker_rank, &dtl_mode, argc, argv))) {
if (DYAD_IS_ERROR (opt_parse (&opt, broker_rank, argc, argv))) {
DYAD_LOG_STDERR ("DYAD_MOD: Cannot parse command line arguments\n");
goto mod_error;
}