Update to use dynamic varibale for operation invoked name in each CCB, instead of using one global name for all CCB --- src/ntf/ntfimcnd/ntfimcn_imm.c | 67 ++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 38 deletions(-)
diff --git a/src/ntf/ntfimcnd/ntfimcn_imm.c b/src/ntf/ntfimcnd/ntfimcn_imm.c index d8084b646..c13cc399e 100644 --- a/src/ntf/ntfimcnd/ntfimcn_imm.c +++ b/src/ntf/ntfimcnd/ntfimcn_imm.c @@ -71,23 +71,11 @@ struct s_get_created_dn { SaNameT objectName; } s_get_created_dn; -/* Used with function get_operation_invoke_name_create() */ -struct { - SaNameT iname; - SaNameT *iname_ptr; - -} s_get_operation_invoke_name_create; - -/* Used with function get_operation_invoke_name_modify() --*/ -struct { - SaNameT iname; - SaNameT *iname_ptr; -} s_get_operation_invoke_name_modify; - #define NOTIFYING_OBJECT "safApp=safImmService" static bool initializeImmOmHandle(SaImmHandleT* immOmHandle); static void finalizeImmOmHandle(SaImmHandleT immOmHandle); +static void free_ccb_data(CcbUtilCcbData_t *ccb_data); /** * Get a class description for the given className @@ -288,12 +276,25 @@ static SaNameT *get_created_dn(const SaImmClassNameT className, return &s_get_created_dn.objectName; } +/** + * Free memory for CcbUtilCcbData + * + * @param ccb_data[in] + * + * @return None + */ +static void free_ccb_data(CcbUtilCcbData_t *ccb_data) { + if (ccb_data != NULL) { + osaf_extended_name_free(ccb_data->userData); + if (ccb_data->userData != NULL) free(ccb_data->userData); + ccbutil_deleteCcbData(ccb_data); + } +} + /** * Get the operation invoker name. * If ccb id is 0 or >0 return the value in SaImmAttrImplementerName or * SaImmAttrAdminOwnerName respective - * Note: - * Uses in file global struct s_get_operation_invoke_name_create * * @param ccbId[in] * @param attr[in] @@ -307,12 +308,10 @@ get_operation_invoke_name_create(SaImmOiCcbIdT ccbId, { int i = 0; char *attrName; + SaNameT* operation_invoke_name = NULL; TRACE_ENTER(); - s_get_operation_invoke_name_create.iname_ptr = - &s_get_operation_invoke_name_create.iname; - if (ccbId == 0) { attrName = NTFIMCN_IMPLEMENTER_NAME; } else { @@ -320,13 +319,12 @@ get_operation_invoke_name_create(SaImmOiCcbIdT ccbId, } /* Get the value from Admin owner name or Implementer name */ - osaf_extended_name_free(&s_get_operation_invoke_name_create.iname); - osaf_extended_name_clear(&s_get_operation_invoke_name_create.iname); + operation_invoke_name = malloc(sizeof(SaNameT)); for (i = 0; attr[i] != NULL; i++) { if (strcmp(attr[i]->attrName, attrName) == 0) { osaf_extended_name_alloc( *((char **)attr[i]->attrValues[0]), - &s_get_operation_invoke_name_create.iname); + operation_invoke_name); goto done; } } @@ -336,7 +334,7 @@ get_operation_invoke_name_create(SaImmOiCcbIdT ccbId, done: TRACE_LEAVE(); - return s_get_operation_invoke_name_create.iname_ptr; + return operation_invoke_name; } /** @@ -344,8 +342,6 @@ done: * If ccb id is 0 or >0 return the value in SaImmAttrImplementerName or * SaImmAttrAdminOwnerName respective. * - * Note: - * * @param ccbId[in] * @param attrMods[in] * @@ -358,12 +354,10 @@ get_operation_invoke_name_modify(SaImmOiCcbIdT ccbId, { int i = 0; char *attrName; + SaNameT* operation_invoke_name = NULL; TRACE_ENTER(); - s_get_operation_invoke_name_modify.iname_ptr = - &s_get_operation_invoke_name_modify.iname; - if (ccbId == 0) { attrName = NTFIMCN_IMPLEMENTER_NAME; } else { @@ -371,13 +365,12 @@ get_operation_invoke_name_modify(SaImmOiCcbIdT ccbId, } /* Get the value from Admin owner name or Implementer name */ - osaf_extended_name_free(&s_get_operation_invoke_name_modify.iname); - osaf_extended_name_clear(&s_get_operation_invoke_name_modify.iname); + operation_invoke_name = malloc(sizeof(SaNameT)); for (i = 0; attrMods[i] != NULL; i++) { if (strcmp(attrMods[i]->modAttr.attrName, attrName) == 0) { osaf_extended_name_alloc( *((char **)attrMods[i]->modAttr.attrValues[0]), - &s_get_operation_invoke_name_modify.iname); + operation_invoke_name); goto done; } } @@ -387,7 +380,7 @@ get_operation_invoke_name_modify(SaImmOiCcbIdT ccbId, done: TRACE_LEAVE(); - return s_get_operation_invoke_name_modify.iname_ptr; + return operation_invoke_name; } /** @@ -435,7 +428,7 @@ static SaAisErrorT saImmOiCcbObjectDeleteCallback(SaImmOiHandleT immOiHandle, goto done; } - ccbutil_deleteCcbData(ccbUtilCcbData); + free_ccb_data(ccbUtilCcbData); if (internal_rc != 0) { LOG_ER("%s send_object_create_notification fail", @@ -514,7 +507,7 @@ saImmOiCcbObjectCreateCallback(SaImmOiHandleT immOiHandle, SaImmOiCcbIdT ccbId, internal_rc = ntfimcn_send_object_create_notification( ccbUtilOperationData, rdn_attr_name, SA_FALSE); - ccbutil_deleteCcbData(ccbUtilCcbData); + free_ccb_data(ccbUtilCcbData); if (internal_rc != 0) { LOG_ER("%s send_object_create_notification fail", @@ -578,7 +571,7 @@ saImmOiCcbObjectModifyCallback(SaImmOiHandleT immOiHandle, SaImmOiCcbIdT ccbId, internal_rc = ntfimcn_send_object_modify_notification( ccbUtilOperationData, invoker_name_ptr, SA_FALSE); - ccbutil_deleteCcbData(ccbUtilCcbData); + free_ccb_data(ccbUtilCcbData); if (internal_rc != 0) { LOG_ER("%s send_object_modify_notification fail", @@ -613,7 +606,7 @@ static void saImmOiCcbAbortCallback(SaImmOiHandleT immOiHandle, TRACE_ENTER(); if ((ccbUtilCcbData = ccbutil_findCcbData(ccbId)) != NULL) { - ccbutil_deleteCcbData(ccbUtilCcbData); + free_ccb_data(ccbUtilCcbData); } else { LOG_ER("%s: Failed to find CCB object for ccb Id %llu", __FUNCTION__, ccbId); @@ -723,9 +716,7 @@ static void saImmOiCcbApplyCallback(SaImmOiHandleT immOiHandle, } done: - if (ccbUtilCcbData != NULL) { - ccbutil_deleteCcbData(ccbUtilCcbData); - } + free_ccb_data(ccbUtilCcbData); TRACE_LEAVE(); if (internal_rc != 0) { /* If we fail to send a notification we exit. This will signal -- 2.15.1 ------------------------------------------------------------------------------ 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 Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel