Skip to content

Commit

Permalink
broker: unregister message handlers on exit
Browse files Browse the repository at this point in the history
Problem: broker exits without freeing message handlers
associated with internal services.

Add broker_remove_service() to do this, and call it
from the broker exit path.
  • Loading branch information
garlick committed Nov 11, 2017
1 parent 46310aa commit 09c86ab
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/broker/broker.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ static void broker_handle_signals (broker_ctx_t *ctx, zlist_t *sigwatchers);
static void broker_unhandle_signals (zlist_t *sigwatchers);

static void broker_add_services (broker_ctx_t *ctx);
static void broker_remove_services (void);

static int load_module_byname (broker_ctx_t *ctx, const char *name,
const char *argz, size_t argz_len,
Expand Down Expand Up @@ -669,6 +670,7 @@ int main (int argc, char *argv[])
hello_destroy (ctx.hello);
attr_destroy (ctx.attrs);
shutdown_destroy (ctx.shutdown);
broker_remove_services ();
flux_close (ctx.h);
flux_reactor_destroy (ctx.reactor);
if (ctx.subscriptions) {
Expand Down Expand Up @@ -1743,6 +1745,13 @@ static void broker_add_services (broker_ctx_t *ctx)
log_err_exit ("error registering message handlers");
}

/* Unregister message handlers
*/
static void broker_remove_services (void)
{
flux_msg_handler_delvec (handlers);
}

/**
** reactor callbacks
**/
Expand Down

0 comments on commit 09c86ab

Please sign in to comment.