Skip to content

Commit

Permalink
fixup! shell: watch for R updates
Browse files Browse the repository at this point in the history
  • Loading branch information
grondo committed Oct 30, 2023
1 parent ffac57c commit a80c8b4
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/shell/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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:
*/
Expand Down

0 comments on commit a80c8b4

Please sign in to comment.