From a80c8b4db3754a4fd839b7a38fc35e49116a4488 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Mon, 30 Oct 2023 16:35:22 -0700 Subject: [PATCH] fixup! shell: watch for R updates --- src/shell/info.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/shell/info.c b/src/shell/info.c index f2e069f57978..90b86fe4a005 100644 --- a/src/shell/info.c +++ b/src/shell/info.c @@ -68,8 +68,14 @@ static flux_future_t *lookup_jobspec (flux_t *h, flux_jobid_t jobid) return f; } -static void resource_watch_update (struct shell_info *info) +/* Unpack R from a job-info.update-watch response and update the + * shell's internal info->R and info->rcalc. If a response can't be + * unpacked or rcalc_create_json() fails, just ignore this response + * and let caller decide if the error is fatal. + */ +static int resource_watch_update (struct shell_info *info) { + int rc = -1; flux_future_t *f = info->R_watch_future; json_t *R = NULL; json_t *tmp_R; @@ -93,17 +99,20 @@ static void resource_watch_update (struct shell_info *info) tmp_rcalc = info->rcalc; info->rcalc = rcalc; rcalc = tmp_rcalc; + rc = 0; out: rcalc_destroy (rcalc); json_decref (R); flux_future_reset (f); + return rc; } static void R_update_cb (flux_future_t *f, void *arg) { flux_shell_t *shell = arg; - resource_watch_update (shell->info); + if (resource_watch_update (shell->info) < 0) + return; /* Destroy cached shell "info" JSON object otherwise plugins will * not see the updated R @@ -174,9 +183,11 @@ static int shell_init_jobinfo (flux_shell_t *shell, struct shell_info *info) goto out; } - /* Get initial version of R from initial job-info watch response: + /* Synchronously get initial version of R from first job-info + * watch response: */ - resource_watch_update (info); + if (resource_watch_update (info) < 0) + goto out; /* Register callback for future R updates: */