Skip to content

Commit

Permalink
qmanager: Add catch-all exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dongahn committed Jul 8, 2019
1 parent f37fa90 commit fb40eb3
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions qmanager/modules/qmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ extern "C" void jobmanager_alloc_cb (flux_t *h, const flux_msg_t *msg,
}
job->jobspec = jobspec;
job->msg = flux_msg_copy (msg, true);
ctx->queue->insert (job);

if (ctx->queue->insert (job) < 0) {
flux_log_error (h, "%s: queue insert", __FUNCTION__);
return;
}
if (ctx->queue->run_sched_loop ((void *)ctx->h, true) < 0) {
flux_log (ctx->h, LOG_DEBUG,
"%s: return code < 0 from schedule loop", __FUNCTION__);
Expand Down Expand Up @@ -205,12 +207,17 @@ static void qmanager_destroy (qmanager_ctx_t *ctx)
extern "C" int mod_main (flux_t *h, int argc, char **argv)
{
int rc = -1;
qmanager_ctx_t *ctx = NULL;
if (!(ctx = qmanager_new (h)))
flux_log_error (h, "%s: qmanager_new", __FUNCTION__);
if ((rc = flux_reactor_run (flux_get_reactor (h), 0)) < 0)
flux_log_error (h, "%s: flux_reactor_run", __FUNCTION__);
qmanager_destroy (ctx);
try {
qmanager_ctx_t *ctx = NULL;
if (!(ctx = qmanager_new (h)))
flux_log_error (h, "%s: qmanager_new", __FUNCTION__);
if ((rc = flux_reactor_run (flux_get_reactor (h), 0)) < 0)
flux_log_error (h, "%s: flux_reactor_run", __FUNCTION__);
qmanager_destroy (ctx);
}
catch (std::exception &e) {
flux_log_error (h, "%s: %s", __FUNCTION__, e.what ());
}
return rc;
}

Expand Down

0 comments on commit fb40eb3

Please sign in to comment.