Skip to content

Commit

Permalink
modules/kvs: Unsubscribe namespace-removed event
Browse files Browse the repository at this point in the history
When a namespace is removed, unsubscribe from the
kvs.namespace-removed-<NS> event.

Fixes #2762
  • Loading branch information
chu11 committed Feb 26, 2020
1 parent 6731200 commit ab0008e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/modules/kvs/kvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ static int event_unsubscribe (kvs_ctx_t *ctx, const char *ns)
{
char *setroot_topic = NULL;
char *error_topic = NULL;
char *removed_topic = NULL;
int rc = -1;

if (asprintf (&setroot_topic, "kvs.setroot-%s", ns) < 0) {
Expand All @@ -262,10 +263,21 @@ static int event_unsubscribe (kvs_ctx_t *ctx, const char *ns)
goto cleanup;
}

if (asprintf (&removed_topic, "kvs.namespace-removed-%s", ns) < 0) {
errno = ENOMEM;
goto cleanup;
}

if (flux_event_subscribe (ctx->h, removed_topic) < 0) {
flux_log_error (ctx->h, "flux_event_subscribe");
goto cleanup;
}

rc = 0;
cleanup:
free (setroot_topic);
free (error_topic);
free (removed_topic);
return rc;
}

Expand Down

0 comments on commit ab0008e

Please sign in to comment.