static void job_state_cb (flux_t h, flux_msg_handler_t *w, const flux_msg_t *msg, void *arg) { int64_t jobid = -1; json_object *o = NULL; const char *topic = NULL; const char *json_str = NULL; const char *state = NULL; int len = 12; if (flux_msg_get_topic (msg, &topic) < 0) goto done; if (flux_event_decode (msg, NULL, &json_str) < 0 || !(o = Jfromstr (json_str)) || !Jget_int64 (o, "lwj", &jobid)) { flux_log (h, LOG_ERR, "%s: bad message", __FUNCTION__); goto done; } if (strncmp (topic, "jsc", 3) == 0) len = 10; state = topic + len; if (strcmp (state, jsc_job_num2state (J_RESERVED)) == 0) fixup_newjob_event (h, jobid); if (invoke_cbs (h, jobid, get_update_jcb (h, jobid, state), 0) < 0) flux_log (h, LOG_ERR, "job_state_cb: failed to invoke callbacks"); if (job_is_finished (state)) delete_jobinfo (h, jobid); done: return; }
static void job_state_cb (flux_t *h, flux_msg_handler_t *mh, const flux_msg_t *msg, void *arg) { json_object *jcb = NULL; int64_t jobid = -1; const char *topic = NULL; const char *state = NULL; const char *kvs_path = NULL; int len = 12; if (flux_msg_get_topic (msg, &topic) < 0) goto done; if (flux_event_unpack (msg, NULL, "{ s:I }", "lwj", &jobid) < 0) { flux_log (h, LOG_ERR, "%s: bad message", __FUNCTION__); goto done; } if (!flux_event_unpack (msg, NULL, "{ s:s }", "kvs_path", &kvs_path)) { if (jscctx_add_jobid_path (getctx (h), jobid, kvs_path) < 0) flux_log_error (h, "jscctx_add_jobid_path"); } if (strncmp (topic, "jsc", 3) == 0) len = 10; state = topic + len; if (strcmp (state, jsc_job_num2state (J_RESERVED)) == 0) fixup_newjob_event (h, jobid); if (invoke_cbs (h, jobid, jcb = get_update_jcb (h, jobid, state), 0) < 0) flux_log (h, LOG_ERR, "job_state_cb: failed to invoke callbacks"); if (job_is_finished (state)) delete_jobinfo (h, jobid); done: Jput (jcb); return; }