From 746eeca4bfcf80b9f38aa126490bafb32e30be1d Mon Sep 17 00:00:00 2001
From: Utz-Uwe Haus <uhaus@cray.com>
Date: Mon, 20 Sep 2021 17:22:43 +0200
Subject: [PATCH] Add ctime to translated events, populate from Pool Events

---
 include/maestro/pool.h          | 1 +
 maestro/subscription_registry.c | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/include/maestro/pool.h b/include/maestro/pool.h
index a37e1d2d..532b7282 100644
--- a/include/maestro/pool.h
+++ b/include/maestro/pool.h
@@ -387,6 +387,7 @@ mstro_subscribe(mstro_cdo_selector cdos, mstro_pool_event_kinds events,
 struct mstro_pool_event_ {
   enum mstro_pool_event_kind kind;  /**< the event kind */
   uint64_t serial;             /**< the event identifier */
+  mstro_nanosec_t  ctime;      /**< the time the event was created at the source */
   union {
     /* for DECLARE events */
     struct {
diff --git a/maestro/subscription_registry.c b/maestro/subscription_registry.c
index bd3056a1..0ccd7c6d 100644
--- a/maestro/subscription_registry.c
+++ b/maestro/subscription_registry.c
@@ -1863,6 +1863,10 @@ mstro_pool_event_consume(const Mstro__Pool__Event *eventmsg)
         eventmsg->kind, ev->kind, mstro_pool_event_description(ev->kind));
   ev->serial = eventmsg->serial;
 
+  assert(eventmsg->ctime!=NULL);
+  
+  ev->ctime = (eventmsg->ctime->sec * NSEC_PER_SEC) + eventmsg->ctime->nsec;
+
   switch(ev->kind) {
     case MSTRO_POOL_EVENT_APP_JOIN:
       assert(eventmsg->payload_case==MSTRO__POOL__EVENT__PAYLOAD_JOIN);
-- 
GitLab