From ffa06e6ca88896054e537efd1472fe64de204ef8 Mon Sep 17 00:00:00 2001 From: Christopher Haine <chaine@hpe.com> Date: Fri, 4 Dec 2020 18:28:33 +0100 Subject: [PATCH] offer events resolve names --- maestro/subscription_registry.c | 25 +++++++++---------------- tests/simple_archiver.c | 1 + 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/maestro/subscription_registry.c b/maestro/subscription_registry.c index 7e4f520e..db4402a3 100644 --- a/maestro/subscription_registry.c +++ b/maestro/subscription_registry.c @@ -7,6 +7,8 @@ #include "maestro/i_misc.h" #include "i_event.h" #include "maestro/i_cdo.h" +#include "maestro/cdo.h" + #include "attributes/maestro-schema.h" @@ -1896,23 +1898,14 @@ mstro_pool_event_consume(const Mstro__Pool__Event *eventmsg) && eventmsg->origin_id->id!=MSTRO_APP_ID_INVALID); assert(eventmsg->offer->cdoid!=NULL); ev->offer.appid = eventmsg->origin_id->id; - { - WARN("FIXME: Missing CDO resolver, returning ID string\n"); - struct mstro_cdo_id id = {.qw[0] = eventmsg->offer->cdoid->qw0, - .qw[1] = eventmsg->offer->cdoid->qw1 }; - - WITH_CDO_ID_STR(idstr, &id, { - ev->offer.cdo_name = strdup(idstr); - }); - if(ev->offer.cdo_name == NULL) { - ERR("Failed to allocate event data\n"); - free(ev); - return MSTRO_NOMEM; - } - - DEBUG("Event: OFFER for |%s| from %" PRIu64 "\n", + const char* cdo_name; + cdo_name = malloc(MSTRO_CDO_NAME_MAX); + assert(cdo_name!=NULL); + mstro_status s = mstro__subscr_resolver_lookup_cdoid( + (struct mstro_cdo_id*)eventmsg->offer->cdoid, &cdo_name); + ev->offer.cdo_name = (char*)cdo_name; + DEBUG("Event: OFFER for |%s| from %" PRIu64 "\n", ev->offer.cdo_name, ev->offer.appid); - } break; case MSTRO_POOL_EVENT_SEAL: diff --git a/tests/simple_archiver.c b/tests/simple_archiver.c index 6e9a2528..1bf74c66 100644 --- a/tests/simple_archiver.c +++ b/tests/simple_archiver.c @@ -147,6 +147,7 @@ CHEAT_TEST(simple_archiver, switch(tmp->kind) { case MSTRO_POOL_EVENT_OFFER: /* FIXME: Immediately post a REQUIRE for it */ + fprintf(stderr, "Spotted an OFFER for CDO (`%s`)\n", e->offer.cdo_name); case MSTRO_POOL_EVENT_DECLARE: case MSTRO_POOL_EVENT_DISPOSE: -- GitLab