From 121dd172adc8e3c9de3c0934e6d347516e9883bf Mon Sep 17 00:00:00 2001
From: Ali Mohammed <ali.mohammed@hpe.com>
Date: Mon, 5 Dec 2022 19:11:02 +0200
Subject: [PATCH] check withdraw queue after retracts

---
 include/maestro/i_pool_manager_registry.h | 6 +++++-
 maestro/pool_manager.c                    | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/maestro/i_pool_manager_registry.h b/include/maestro/i_pool_manager_registry.h
index 90452dea..b16e745b 100644
--- a/include/maestro/i_pool_manager_registry.h
+++ b/include/maestro/i_pool_manager_registry.h
@@ -177,7 +177,6 @@ mstro_status
 mstro_pm_app_lookup(mstro_app_id appid,
                     struct mstro_pm_app_registry_entry **app_entry_p);
 
-
 /** A table entry for a CDO reference in the global pool. Abstract, so
  * that implementations of a distributed registry do not need to
  * change the interface */
@@ -267,6 +266,11 @@ mstro_pm_cdo_registry_withdraw(const struct mstro_cdo_id *cdoid,
                                mstro_event continuation_event);
 
 
+/* Check blocked withdraws in g_mstro_pm_withdraw_queue -- perform possible withdraws after CDO state changes*/
+mstro_status
+mstro_pm__handle_withdraws(void);
+
+
 /** Check if the cdo is still in transport before disposing
  *  return MSTRO_WOULDBLOCK if the cdo is in transport
  *  return MSRO_OK otherwise
diff --git a/maestro/pool_manager.c b/maestro/pool_manager.c
index 0844deb6..131c8bd9 100644
--- a/maestro/pool_manager.c
+++ b/maestro/pool_manager.c
@@ -1470,6 +1470,14 @@ mstro_pm__handle_retract_phase2(mstro_event event,
                        app_id, idstr);
                   );
 
+  /* piggy-back to handle any withdraws that have become possible at this point */
+    s = mstro_pm__handle_withdraws();
+    if(s!=MSTRO_OK) {
+      ERR("Failure processing withdraw-queue entries\n");
+      goto BAILOUT_FREE;
+    }
+
+
   /* produce require:after event */
   Mstro__Pool__Event ev = MSTRO__POOL__EVENT__INIT;
   /* serial and handle set later */
-- 
GitLab