Add new set to IMMA_CLIENT_NODE to store the invocations.
The invocation is added to the set when dispatching the callback
and is removed from the set in saImmOiAdminOperationResult.
---
 src/imm/agent/imma_cb.h      |  5 +++++
 src/imm/agent/imma_db.cc     |  2 +-
 src/imm/agent/imma_oi_api.cc | 14 ++++++++++++--
 src/imm/agent/imma_om_api.cc |  6 +++---
 src/imm/agent/imma_proc.cc   |  1 +
 5 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/imm/agent/imma_cb.h b/src/imm/agent/imma_cb.h
index c478990..454ad11 100644
--- a/src/imm/agent/imma_cb.h
+++ b/src/imm/agent/imma_cb.h
@@ -19,6 +19,8 @@
 #ifndef IMM_AGENT_IMMA_CB_H_
 #define IMM_AGENT_IMMA_CB_H_
 
+#include <set>
+
 /* Node to store Ccb info for OI client */
 struct imma_callback_info;
 
@@ -95,6 +97,9 @@ typedef struct imma_client_node {
   SaTimeT
       oiTimeout; /* Timeout for OI callback. If the value is 0, the default
                     timeout (6s) will be used */
+
+  /* Current callback invocations */
+  std::set<SaInvocationT> callbackInvocationSet;
 } IMMA_CLIENT_NODE;
 
 /* Node to store adminOwner info */
diff --git a/src/imm/agent/imma_db.cc b/src/imm/agent/imma_db.cc
index 1ed590e..cc771f7 100644
--- a/src/imm/agent/imma_db.cc
+++ b/src/imm/agent/imma_db.cc
@@ -113,7 +113,7 @@ uint32_t imma_client_node_delete(IMMA_CB *cb, 
IMMA_CLIENT_NODE *cl_node) {
     imma_oi_ccb_record_delete(cl_node, cl_node->activeOiCcbs->ccbId);
   }
 
-  free(cl_node);
+  delete cl_node;
 
   return rc;
 }
diff --git a/src/imm/agent/imma_oi_api.cc b/src/imm/agent/imma_oi_api.cc
index 3451c85..28cea8a 100644
--- a/src/imm/agent/imma_oi_api.cc
+++ b/src/imm/agent/imma_oi_api.cc
@@ -152,7 +152,7 @@ SaAisErrorT initialize_common(SaImmOiHandleT *immOiHandle,
   *immOiHandle = 0;
 
   /* Alloc the client info data structure & put it in the Pat tree */
-  cl_node = (IMMA_CLIENT_NODE *)calloc(1, sizeof(IMMA_CLIENT_NODE));
+  cl_node = new IMMA_CLIENT_NODE{};
   if (cl_node == NULL) {
     TRACE_2("ERR_NO_MEMORY: IMMA_CLIENT_NODE alloc failed");
     rc = SA_AIS_ERR_NO_MEMORY;
@@ -384,7 +384,7 @@ version_fail:
   }
 
 lock_fail:
-  if (rc != SA_AIS_OK) free(cl_node);
+  if (rc != SA_AIS_OK) delete cl_node;
 
 cnode_alloc_fail:
 
@@ -1004,6 +1004,16 @@ static SaAisErrorT admin_op_result_common(
     goto stale_handle;
   }
 
+  if (cl_node->callbackInvocationSet.find(invocation)
+      == cl_node->callbackInvocationSet.end()) {
+    LOG_WA(
+        "ERR_INVALID_PARAM: Illegal SaInvocationT value provided in 
saImmOiAdminOperationResult");
+    rc = SA_AIS_ERR_INVALID_PARAM;
+    goto stale_handle;
+  } else {
+    cl_node->callbackInvocationSet.erase(invocation);
+  }
+
   /* populate the structure */
   memset(&adminOpRslt_evt, 0, sizeof(IMMSV_EVT));
   adminOpRslt_evt.type = IMMSV_EVT_TYPE_IMMND;
diff --git a/src/imm/agent/imma_om_api.cc b/src/imm/agent/imma_om_api.cc
index 51822f0..7da8a14 100644
--- a/src/imm/agent/imma_om_api.cc
+++ b/src/imm/agent/imma_om_api.cc
@@ -126,7 +126,7 @@ SaAisErrorT saImmOmInitialize_o2(SaImmHandleT *immHandle,
   }
 
   /* Alloc the client info data structure */
-  cl_node = (IMMA_CLIENT_NODE *)calloc(1, sizeof(IMMA_CLIENT_NODE));
+  cl_node = new IMMA_CLIENT_NODE{};
 
   if (cl_node == NULL) {
     TRACE_4("ERR_NO_MEMORY: IMMA_CLIENT_NODE alloc failed");
@@ -186,7 +186,7 @@ SaAisErrorT saImmOmInitialize(SaImmHandleT *immHandle,
   }
 
   /* Alloc the client info data structure */
-  cl_node = (IMMA_CLIENT_NODE *)calloc(1, sizeof(IMMA_CLIENT_NODE));
+  cl_node = new IMMA_CLIENT_NODE{};
 
   if (cl_node == NULL) {
     TRACE_4("ERR_NO_MEMORY: IMMA_CLIENT_NODE alloc failed");
@@ -467,7 +467,7 @@ end:
       rc = SA_AIS_ERR_LIBRARY;
     }
 
-    free(cl_node);
+    delete cl_node;
   }
 
   TRACE_LEAVE();
diff --git a/src/imm/agent/imma_proc.cc b/src/imm/agent/imma_proc.cc
index cca734f..886b50c 100644
--- a/src/imm/agent/imma_proc.cc
+++ b/src/imm/agent/imma_proc.cc
@@ -2221,6 +2221,7 @@ static bool imma_process_callback_info(IMMA_CB *cb, 
IMMA_CLIENT_NODE *cl_node,
           }
         }
       }
+      cl_node->callbackInvocationSet.insert(callback->invocation);
       if (cl_node->o.iCallbk.saImmOiAdminOperationCallback &&
           isExtendedNameValid && !isAttrExtendedName) {
         if (cl_node->isImmA2fCbk) {
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to