1) The trace showed that during saImmOiCcbCompletedCallback, when exchanged messages to fetch the old values, message IMMA_CALLBACK_OI_CCB_APPLY is posed in the mailbox.
It is concluded that the old values are no longer available at saImmOiCcbObjectModifyCallback. 2) It also expect comments if major changes of implementaton is needed. --- src/ntf/Makefile.am | 2 + src/ntf/ntfimcnd/ntfimcn_common.c | 378 ++++++++++++++++++++++++++++++ src/ntf/ntfimcnd/ntfimcn_common.h | 40 ++++ src/ntf/ntfimcnd/ntfimcn_imm.c | 165 ++++++++++++- src/ntf/ntfimcnd/ntfimcn_main.c | 16 +- src/ntf/ntfimcnd/ntfimcn_main.h | 2 + 6 files changed, 597 insertions(+), 6 deletions(-) create mode 100755 src/ntf/ntfimcnd/ntfimcn_common.c create mode 100755 src/ntf/ntfimcnd/ntfimcn_common.h diff --git a/src/ntf/Makefile.am b/src/ntf/Makefile.am index a03eab10c..95210ae5d 100644 --- a/src/ntf/Makefile.am +++ b/src/ntf/Makefile.am @@ -108,6 +108,7 @@ noinst_HEADERS += \ src/ntf/ntfimcnd/ntfimcn_imm.h \ src/ntf/ntfimcnd/ntfimcn_main.h \ src/ntf/ntfimcnd/ntfimcn_notifier.h \ + src/ntf/ntfimcnd/ntfimcn_common.h \ src/ntf/tools/ntfclient.h \ src/ntf/tools/ntfconsumer.h @@ -171,6 +172,7 @@ bin_osafntfimcnd_CPPFLAGS = \ bin_osafntfimcnd_SOURCES = \ src/ntf/ntfimcnd/ntfimcn_main.c \ src/ntf/ntfimcnd/ntfimcn_notifier.c \ + src/ntf/ntfimcnd/ntfimcn_common.c \ src/ntf/ntfimcnd/ntfimcn_imm.c bin_osafntfimcnd_LDADD = \ diff --git a/src/ntf/ntfimcnd/ntfimcn_common.c b/src/ntf/ntfimcnd/ntfimcn_common.c new file mode 100755 index 000000000..f09da3f48 --- /dev/null +++ b/src/ntf/ntfimcnd/ntfimcn_common.c @@ -0,0 +1,378 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include "ntfimcn_common.h" +#include "osaf/immutil/immutil.h" +#include "ntfimcn_main.h" + +#include "base/logtrace.h" + +const int DBG_MX_LEN = 1024; + +extern ntfimcn_cb_t ntfimcn_cb; /* See ntfimcn_main.c */ + +const char *CcbUtilOperationType_Str[] = { "CCBUTIL_CREATE", "CCBUTIL_DELETE", + "CCBUTIL_MODIFY" }; + +void dbg_print_attr_value(SaImmValueTypeT attrValueType, + SaImmAttrValueT *attrValue, char *outbuffer) { + switch (attrValueType) { + case SA_IMM_ATTR_SAINT32T: + snprintf(outbuffer, DBG_MX_LEN, "%d (0x%x)", *((SaInt32T*) attrValue), + *((SaInt32T*) attrValue)); + break; + case SA_IMM_ATTR_SAUINT32T: + snprintf(outbuffer, DBG_MX_LEN, "%u (0x%x)", *((SaUint32T*) attrValue), + *((SaUint32T*) attrValue)); + break; + case SA_IMM_ATTR_SAINT64T: + snprintf(outbuffer, DBG_MX_LEN, "%lld (0x%llx)", *((SaInt64T*) attrValue), + *((SaInt64T*) attrValue)); + break; + case SA_IMM_ATTR_SAUINT64T: + snprintf(outbuffer, DBG_MX_LEN, "%llu (0x%llx)", *((SaUint64T*) attrValue), + *((SaUint64T*) attrValue)); + break; + case SA_IMM_ATTR_SAFLOATT: + snprintf(outbuffer, DBG_MX_LEN, "%.8g", *((SaFloatT*) attrValue)); + break; + case SA_IMM_ATTR_SADOUBLET: + snprintf(outbuffer, DBG_MX_LEN, "%.17g", *((SaDoubleT*) attrValue)); + break; + case SA_IMM_ATTR_SANAMET: { + SaNameT *myNameT = (SaNameT*) attrValue; + snprintf(outbuffer, DBG_MX_LEN, "%s (%zu)", saAisNameBorrow(myNameT), + strlen(saAisNameBorrow(myNameT))); + break; + } + case SA_IMM_ATTR_SASTRINGT: + snprintf(outbuffer, DBG_MX_LEN, "%s", *((char**) attrValue)); + break; + case SA_IMM_ATTR_SAANYT: { + SaAnyT *anyp = (SaAnyT*) attrValue; + char *cur = outbuffer; + unsigned int i = 0; + if (anyp->bufferSize) { + cur += snprintf(cur, DBG_MX_LEN, "%s", "0x"); + for (; i < anyp->bufferSize; i++) { + if (((int) anyp->bufferAddr[i]) < 0x10) { + cur += snprintf(cur, DBG_MX_LEN, "%s", "0"); + } + cur += snprintf(cur, DBG_MX_LEN, "%x", (int) anyp->bufferAddr[i]); + } + } + cur += snprintf(cur, DBG_MX_LEN, " size(%u) ", + (unsigned int) anyp->bufferSize); + break; + } + + default: + snprintf(outbuffer, DBG_MX_LEN, "%s", "Unknown "); + break; + } + +} + +char* dbg_get_attr_type_name(SaImmValueTypeT attrValueType) { + switch (attrValueType) { + case SA_IMM_ATTR_SAINT32T: + return "SA_INT32_T"; + break; + case SA_IMM_ATTR_SAUINT32T: + return "SA_UINT32_T"; + break; + case SA_IMM_ATTR_SAINT64T: + return "SA_INT64_T"; + break; + case SA_IMM_ATTR_SAUINT64T: + return "SA_UINT64_T"; + break; + case SA_IMM_ATTR_SATIMET: + return "SA_TIME_T"; + break; + case SA_IMM_ATTR_SANAMET: + return "SA_NAME_T"; + break; + case SA_IMM_ATTR_SAFLOATT: + return "SA_FLOAT_T"; + break; + case SA_IMM_ATTR_SADOUBLET: + return "SA_DOUBLE_T"; + break; + case SA_IMM_ATTR_SASTRINGT: + return "SA_STRING_T"; + break; + case SA_IMM_ATTR_SAANYT: + return "SA_ANY_T"; + break; + default: + return "Unknown"; + break; + } +} + +void dbg_trace_attr_mod(const SaImmAttrModificationT_2 **attrMods) { + TRACE_ENTER(); + int i = 0; + const SaImmAttrModificationT_2 *attrmod; + SaImmAttrValuesT_2 attr; + + char buff[DBG_MX_LEN]; + char *pbuff = buff; + for (i = 0; (attrmod = attrMods[i]) != NULL; ++i) { + //while ((attrmod = attrMods[i++]) != NULL) { + attr = attrmod->modAttr; + TRACE("%s, %s", attr.attrName, dbg_get_attr_type_name(attr.attrValueType)); + if (attr.attrValuesNumber > 0) { + for (int j = 0; j < attr.attrValuesNumber; ++j) { + dbg_print_attr_value(attr.attrValueType, attr.attrValues[j], pbuff); + TRACE("%s", pbuff); + } + } else { + TRACE("<Empty>"); + } + } + TRACE_LEAVE2("No of attr printed = %d", i); +} + +void dbg_trace_attr(const SaImmAttrValuesT_2 **attrs) { + + TRACE_ENTER(); + + int i = 0; + const SaImmAttrValuesT_2 *attr; + char buff[DBG_MX_LEN]; + char *pbuff = buff; + do { + if (attrs == NULL) { + TRACE("Attempt to trace NULL SaImmAttrValuesT_2*"); + break; + } + for (i = 0; (attr = attrs[i]) != NULL; ++i) { + TRACE("%s, %s", attr->attrName, + dbg_get_attr_type_name(attr->attrValueType)); + if (attr->attrValuesNumber > 0) { + for (int j = 0; j < attr->attrValuesNumber; ++j) { + dbg_print_attr_value(attr->attrValueType, + attr->attrValues[j], pbuff); + TRACE("%s", pbuff); + } + } else { + TRACE("<Empty>"); + } + } + } while (SA_FALSE); + TRACE_LEAVE2("No of attr printed = %d", i); +} + +// TODO: handle error cases and +// Free memory after use +SaAisErrorT get_current_attr(const SaNameT *objectName, + const SaImmAttrModificationT_2 **attrMods, SaImmAttrValuesT_2 ***curAttr, + SaBoolT copy) { + TRACE_ENTER(); + + SaAisErrorT rc = SA_AIS_OK; + SaImmAttrNameT *attrNames = NULL; + int len = 1; + for (int i = 0; attrMods[i] != NULL; ++i) { + attrNames = realloc(attrNames, ++len * sizeof(SaImmAttrNameT)); + attrNames[len - 2] = attrMods[i]->modAttr.attrName; + attrNames[len - 1] = NULL; + } + TRACE("len = %d", len); + for (int i = 0; attrNames[i] != NULL; ++i) { + TRACE("attrNames[%d] = %s", i, attrNames[i]); + } + // Get current attributes for the given attribute names + SaImmAttrValuesT_2 **resAttr; + rc = immutil_saImmOmAccessorGet_2(ntfimcn_cb.immAccessorHandle, objectName, + attrNames, &resAttr); + if (SA_AIS_OK == rc) { + //*curAtt = resAttr + if (copy) { + imm_attributes_cpy(curAttr, (const SaImmAttrValuesT_2**) resAttr); + } else { + *curAttr = resAttr; + } + dbg_trace_attr((const SaImmAttrValuesT_2**) *curAttr); + } else { + TRACE("immutil_saImmOmAccessorGet_2 failed"); + // Do nothing for now; come back later + } + + free(attrNames); + TRACE_LEAVE2("rc = %u", rc); + return rc; +} + +void free_imcnUserData(void *data) { + + if (data == NULL) + return; + ImcnUserData_t* imcnData = (ImcnUserData_t*) data; + free_imm_attr(imcnData->currAttr); + free(imcnData); +} + +// Might be removed +ImcnUserData_t* create_imcnUserData() { + ImcnUserData_t *data = malloc(sizeof(ImcnUserData_t)); + if (data != NULL) { + data->currAttrAvailable = SA_FALSE; + data->errorCode = SA_AIS_ERR_UNAVAILABLE; + data->currAttr = NULL; + } + return data; +} + +static size_t imm_attr_value_size(SaImmValueTypeT type) { + size_t valueSize = 0; + + switch (type) { + case SA_IMM_ATTR_SAINT32T: + valueSize = sizeof(SaInt32T); + break; + case SA_IMM_ATTR_SAUINT32T: + valueSize = sizeof(SaUint32T); + break; + case SA_IMM_ATTR_SAINT64T: + valueSize = sizeof(SaInt64T); + break; + case SA_IMM_ATTR_SAUINT64T: + valueSize = sizeof(SaUint64T); + break; + case SA_IMM_ATTR_SATIMET: + valueSize = sizeof(SaTimeT); + break; + case SA_IMM_ATTR_SANAMET: + valueSize = sizeof(SaNameT); + break; + case SA_IMM_ATTR_SAFLOATT: + valueSize = sizeof(SaFloatT); + break; + case SA_IMM_ATTR_SADOUBLET: + valueSize = sizeof(SaDoubleT); + break; + case SA_IMM_ATTR_SASTRINGT: + valueSize = sizeof(SaStringT); + break; + case SA_IMM_ATTR_SAANYT: + valueSize = sizeof(SaAnyT); + break; + } + return valueSize; + +} + +static void imm_attr_cpy(SaImmAttrValuesT_2 **dest, + const SaImmAttrValuesT_2 *src) { + + SaImmAttrValuesT_2 *tdest = + (SaImmAttrValuesT_2*) calloc(1, sizeof(SaImmAttrValuesT_2)); + tdest->attrName = strdup(src->attrName); + + tdest->attrValueType = src->attrValueType; + tdest->attrValuesNumber = src->attrValuesNumber; + SaUint32T count = src->attrValuesNumber; + size_t valSize = imm_attr_value_size(src->attrValueType); + if (src->attrValues == NULL) { + *dest = tdest; + return; + } + tdest->attrValues = (SaImmAttrValueT*) malloc( + sizeof(SaImmAttrValueT*) * count); + + for (unsigned int i = 0; i < count; ++i) { + if (src->attrValues[i] == NULL) { + tdest->attrValues[i] = NULL; + continue; + } + tdest->attrValues[i] = malloc(valSize); + switch (src->attrValueType) { + case SA_IMM_ATTR_SASTRINGT: { + //God saves the Queen + *((SaStringT*) tdest->attrValues[i]) = + strdup(*((SaStringT*) src->attrValues[i])); + break; + } + case SA_IMM_ATTR_SANAMET: { + SaNameT* nameSrc = (SaNameT*) src->attrValues[i]; + SaNameT* nameDest = (SaNameT*) tdest->attrValues[i]; + osaf_extended_name_alloc(osaf_extended_name_borrow(nameSrc), nameDest); + break; + } + case SA_IMM_ATTR_SAANYT: { + SaAnyT *anySrc = (SaAnyT*) src->attrValues[i]; + SaAnyT *anyDest = (SaAnyT*) tdest->attrValues[i]; + anyDest->bufferSize = anySrc->bufferSize; + if (anyDest->bufferSize) { + anyDest->bufferAddr = (SaUint8T*) malloc(anyDest->bufferSize); + memcpy(anyDest->bufferAddr, anySrc->bufferAddr, anyDest->bufferSize); + } + else { + anyDest->bufferAddr = NULL; + } + break; + } + default: + memcpy(tdest->attrValues[i], src->attrValues[i], valSize); + break; + } + } + *dest = tdest; +} + +void imm_attributes_cpy(SaImmAttrValuesT_2 ***dest, + const SaImmAttrValuesT_2 **src) { + + *dest = NULL; + if (src == NULL) + return; + + int len = 0; + const SaImmAttrValuesT_2 *p = src[len]; + while (p != NULL) { + p = src[++len]; + } + if (!len) + return; + + SaImmAttrValuesT_2 **attr = + (SaImmAttrValuesT_2**) malloc((len + 1) * sizeof(SaImmAttrValuesT_2*)); + for (int i = 0; i < len; ++i) { + imm_attr_cpy(&attr[i], src[i]); + } + attr[len] = NULL; + *dest = attr; +} + +void free_imm_attr(SaImmAttrValuesT_2 **attrs) +{ + if (attrs == NULL) + return; + SaImmAttrValuesT_2 *attr; + SaImmAttrValueT value; + for (int i = 0; (attr = attrs[i]) != NULL; ++i) { + free(attr->attrName); + if (attr->attrValues == NULL) { + continue; + } + for (unsigned int j = 0; j < attr->attrValuesNumber; ++j) { + value = attr->attrValues[j]; + if (value == NULL) { + continue; + } + if (attr->attrValueType == SA_IMM_ATTR_SASTRINGT) { + free(*((SaStringT*) value)); + } else if (attr->attrValueType == SA_IMM_ATTR_SANAMET) { + osaf_extended_name_free((SaNameT*) value); + } else if (attr->attrValueType == SA_IMM_ATTR_SAANYT) { + free(((SaAnyT*) value)->bufferAddr); + } + free(value); + } + free(attr->attrValues); + free(attr); + } +} diff --git a/src/ntf/ntfimcnd/ntfimcn_common.h b/src/ntf/ntfimcnd/ntfimcn_common.h new file mode 100755 index 000000000..64b26e0b3 --- /dev/null +++ b/src/ntf/ntfimcnd/ntfimcn_common.h @@ -0,0 +1,40 @@ +#ifndef NTF_NTFIMCND_NTFIMCN_COMMON_H_ +#define NTF_NTFIMCND_NTFIMCN_COMMON_H_ + +#include <saNtf.h> +#include <saImmOi.h> +#include <saImmOm.h> +#include "base/osaf_extended_name.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void dbg_print_attr_value(SaImmValueTypeT attrValueType, + SaImmAttrValueT *attrValue, char *outbuffer); +char* dbg_get_attr_type_name(SaImmValueTypeT attrValueType); + +void dbg_trace_attr_mod(const SaImmAttrModificationT_2 **attrMods); +void dbg_trace_attr(const SaImmAttrValuesT_2 **attrs); + +SaAisErrorT get_current_attr(const SaNameT *objectName, + const SaImmAttrModificationT_2 **attrMods, SaImmAttrValuesT_2 ***curAttr, + SaBoolT copy); +void imm_attributes_cpy(SaImmAttrValuesT_2 ***des, + const SaImmAttrValuesT_2 **src); +void free_imm_attr(SaImmAttrValuesT_2 **attrs); + +typedef struct ImcnUserData { + SaBoolT currAttrAvailable; // Indicate if currAttr exists + SaAisErrorT errorCode; // The error code when fetching currAttr fail + SaImmAttrValuesT_2 **currAttr; +} ImcnUserData_t; + +void free_imcnUserData(void *data); +ImcnUserData_t* create_imcnUserData(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/ntf/ntfimcnd/ntfimcn_imm.c b/src/ntf/ntfimcnd/ntfimcn_imm.c index 3f2c1a873..73ec8ab25 100644 --- a/src/ntf/ntfimcnd/ntfimcn_imm.c +++ b/src/ntf/ntfimcnd/ntfimcn_imm.c @@ -40,7 +40,9 @@ #include "ntfimcn_main.h" #include "ntfimcn_notifier.h" +#include "ntfimcn_common.h" +extern const char* CcbUtilOperationType_Str[]; /* * Global variables */ @@ -289,6 +291,12 @@ static void free_ccb_data(CcbUtilCcbData_t *ccb_data) { osaf_extended_name_free(ccb_data->userData); free(ccb_data->userData); } + // Free userData in CcbUtilOperationData + struct CcbUtilOperationData* oper_data = + ccb_data->operationListHead; + for (; oper_data!= NULL; oper_data = oper_data->next) { + free_imcnUserData(oper_data->userData); + } ccbutil_deleteCcbData(ccb_data); } } @@ -404,6 +412,9 @@ static SaAisErrorT saImmOiCcbObjectDeleteCallback(SaImmOiHandleT immOiHandle, int internal_rc = 0; TRACE_ENTER(); + TRACE("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" \ + "saImmOiCcbObjectDeleteCallback\n" \ + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); if ((ccbUtilCcbData = ccbutil_findCcbData(ccbId)) == NULL) { if ((ccbUtilCcbData = ccbutil_getCcbData(ccbId)) == NULL) { @@ -481,6 +492,9 @@ saImmOiCcbObjectCreateCallback(SaImmOiHandleT immOiHandle, SaImmOiCcbIdT ccbId, int internal_rc = 0; TRACE_ENTER(); + TRACE("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" \ + "saImmOiCcbObjectCreateCallback\n" \ + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); dn_ptr = get_created_dn(className, parentName, attr); @@ -548,6 +562,13 @@ saImmOiCcbObjectModifyCallback(SaImmOiHandleT immOiHandle, SaImmOiCcbIdT ccbId, TRACE_ENTER(); + SaConstStringT object_name_str = osaf_extended_name_borrow(objectName); + + TRACE("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" \ + "saImmOiCcbObjectModifyCallback, object_name_str == <%s>\n" \ + "ccbId == <%llu>\n" \ + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n", object_name_str, ccbId); + if ((ccbUtilCcbData = ccbutil_findCcbData(ccbId)) == NULL) { if ((ccbUtilCcbData = ccbutil_getCcbData(ccbId)) == NULL) { LOG_ER("%s: Failed to get CCB object for ccb Id %llu", @@ -556,7 +577,7 @@ saImmOiCcbObjectModifyCallback(SaImmOiHandleT immOiHandle, SaImmOiCcbIdT ccbId, goto done; } invoke_name_ptr = - get_operation_invoke_name_modify(ccbId, attrMods); + get_operation_invoke_name_modify(ccbId, attrMods); ccbUtilCcbData->userData = invoke_name_ptr; } @@ -565,6 +586,28 @@ saImmOiCcbObjectModifyCallback(SaImmOiHandleT immOiHandle, SaImmOiCcbIdT ccbId, SaNameT *invoker_name_ptr; invoker_name_ptr = ccbUtilCcbData->userData; + if (ccbId > 0) { + struct CcbUtilOperationData *ccbOperData; + ccbOperData = ccbUtilCcbData->operationListTail; + dbg_trace_attr_mod(attrMods); + SaImmAttrValuesT_2 **curAttr; + ImcnUserData_t* usrData = create_imcnUserData(); + rc = get_current_attr(objectName, attrMods, &curAttr, SA_TRUE); + usrData->errorCode = rc; + if (SA_AIS_OK == rc) { + usrData->currAttrAvailable = SA_TRUE; + usrData->currAttr = curAttr; + } else { + usrData->currAttrAvailable = SA_FALSE; + } + // Memorize the following saying + // An apple a day keeps the doctor away + if (ccbOperData->userData != NULL) { + TRACE("Data is overwritten here"); + } + ccbOperData->userData = usrData; + } + if (ccbId == 0) { /* Attribute change object create */ ccbUtilOperationData = ccbUtilCcbData->operationListHead; @@ -576,7 +619,7 @@ saImmOiCcbObjectModifyCallback(SaImmOiHandleT immOiHandle, SaImmOiCcbIdT ccbId, if (internal_rc != 0) { LOG_ER("%s send_object_modify_notification fail", - __FUNCTION__); + __FUNCTION__); goto done; } } @@ -586,8 +629,8 @@ done: /* If we fail to send a notification we exit. This will signal * that a notification is missing. */ - LOG_ER("saImmOiCcbObjectModifyCallback Fail, internal_rc=%d", - internal_rc); + LOG_ER("saImmOiCcbObjectModifyCallback Fail, " + "internal_rc=%d", internal_rc); imcn_exit(EXIT_FAILURE); } @@ -625,6 +668,78 @@ static SaAisErrorT saImmOiCcbCompletedCallback(SaImmOiHandleT immOiHandle, SaImmOiCcbIdT ccbId) { /* Nothing to do here */ + /* -------------------*/ + + // The following code tries to fetch the values before they are changed. + // For an applier, it is too late at this callback, since the values + // are already overwritten. + // + // This will be removed before the final review + // + TRACE_ENTER(); + TRACE("\n*************************\n" \ + "saImmOiCcbCompletedCallback\n" \ + "ccbId == <%llu>\n" \ + "*************************\n", ccbId); + + + struct CcbUtilCcbData *ccbUtilCcbData; + int internal_rc = 0; + if ((ccbUtilCcbData = ccbutil_findCcbData(ccbId)) == NULL) { + LOG_ER("%s: Failed to find CCB object for ccb Id %llu", + __FUNCTION__, ccbId); + internal_rc = (-1); + TRACE("ccbutil_findCcbData failed for ccId == <%llu>", ccbId); + goto done; + } + struct CcbUtilOperationData *ccbUtilOperationData; + ccbUtilOperationData = ccbUtilCcbData->operationListHead; + int count = 0; + TRACE("Start loop iterating through all operation data"); + SaAisErrorT rc = SA_AIS_OK; + SaImmAttrValuesT_2 **curAttr; + for (; ccbUtilOperationData != NULL; ccbUtilOperationData = + ccbUtilOperationData->next) { + SaConstStringT objNameStr = saAisNameBorrow( + &ccbUtilOperationData->objectName); + enum CcbUtilOperationType optype = + ccbUtilOperationData->operationType; + TRACE("objNameStr == <%s>, operationType == <%s>", + objNameStr, CcbUtilOperationType_Str[optype]); + if (optype == CCBUTIL_MODIFY) { + TRACE("CCBUTIL_MODIFY operation type"); + const SaImmAttrModificationT_2 **attrMods = + ccbUtilOperationData->param.modify.attrMods; + if (attrMods[0] == NULL) { + TRACE("No mod attr for CCBUTIL_MODIFY"); + } else { + TRACE("**********************"); + rc = get_current_attr( + &ccbUtilOperationData->objectName, + attrMods, &curAttr, SA_FALSE); + if (SA_AIS_OK != rc) { + TRACE("Failed to get " + "current attribute for <%s>", + objNameStr); + } + } + } + ++count; + } + TRACE("Total attr count = %d", count); + TRACE("**********************"); + + done: + //free_ccb_data(ccbUtilCcbData); + TRACE_LEAVE(); + if (internal_rc != 0) { + /* If we fail to send a notification we exit. + * This will signal that a notification + * is missing. + */ + //imcn_exit(EXIT_FAILURE); + } + return SA_AIS_OK; } @@ -644,6 +759,10 @@ static void saImmOiCcbApplyCallback(SaImmOiHandleT immOiHandle, SaUint64T ccb_entries_cnt = 0; TRACE_ENTER(); + TRACE("\n>>>>>>>>>>>>>>>>>>>>>>>>>\n" \ + "saImmOiCcbApplyCallback\n" \ + "ccbId == <%llu>\n" \ + ">>>>>>>>>>>>>>>>>>>>>>>>>\n", ccbId); if ((ccbUtilCcbData = ccbutil_findCcbData(ccbId)) == NULL) { LOG_ER("%s: Failed to find CCB object for ccb Id %llu", @@ -673,6 +792,7 @@ static void saImmOiCcbApplyCallback(SaImmOiHandleT immOiHandle, switch (ccbUtilOperationData->operationType) { case CCBUTIL_CREATE: + TRACE("Apply CCBUTIL_CREATE"); rdn_attr_name = get_rdn_attr_name( ccbUtilOperationData->param.create.className); @@ -689,6 +809,7 @@ static void saImmOiCcbApplyCallback(SaImmOiHandleT immOiHandle, break; case CCBUTIL_DELETE: + TRACE("Apply CCBUTIL_DELETE"); invoke_name_ptr = (SaNameT *)ccbUtilCcbData->userData; if (invoke_name_ptr == NULL) { /* Fix for ticket #2859. @@ -705,7 +826,7 @@ static void saImmOiCcbApplyCallback(SaImmOiHandleT immOiHandle, goto done; } internal_rc = ntfimcn_send_object_delete_notification( - ccbUtilOperationData, invoke_name_ptr, ccbLast); + ccbUtilOperationData, invoke_name_ptr, ccbLast); if (internal_rc != 0) { LOG_ER( "%s send_object_delete_notification %s fail", @@ -717,8 +838,37 @@ static void saImmOiCcbApplyCallback(SaImmOiHandleT immOiHandle, break; case CCBUTIL_MODIFY: + TRACE("Apply CCBUTIL_MODIFY"); invoke_name_ptr = ccbUtilCcbData->userData; + TRACE("CCBUTIL_MODIFY; New attributes"); + dbg_trace_attr_mod( + ccbUtilOperationData->param.modify.attrMods); + TRACE("====================="); + TRACE("CCBUTIL_MODIFY; OLD attributes"); + if (ccbUtilOperationData->userData != NULL) { + ImcnUserData_t* userData = + (ImcnUserData_t*) + ccbUtilOperationData->userData; + if (userData->currAttrAvailable == SA_FALSE) { + TRACE("CCBUTIL_MODIFY; OLD attributes" + "not available; " + "error code <%d>", + userData->errorCode); + } else { + // At the moment, only trace it out + dbg_trace_attr( + (const SaImmAttrValuesT_2 **) + userData->currAttr); + } + + } else { + TRACE("CCBUTIL_MODIFY; OLD attributes " + "cannot be collected"); + // Logging? + } + TRACE("====================="); + /* send_object_modify_notification */ internal_rc = ntfimcn_send_object_modify_notification( ccbUtilOperationData, invoke_name_ptr, ccbLast); @@ -912,6 +1062,11 @@ int ntfimcn_imm_init(ntfimcn_cb_t *cb) if (initializeImmOmHandle(&cb->immOmHandle) == false) { internal_rc = NTFIMCN_INTERNAL_ERROR; } + cb->immAccessorHandle = 0; + if (immutil_saImmOmAccessorInitialize(cb->immOmHandle, + &cb->immAccessorHandle) == false) { + internal_rc = NTFIMCN_INTERNAL_ERROR; + } done: TRACE_LEAVE(); diff --git a/src/ntf/ntfimcnd/ntfimcn_main.c b/src/ntf/ntfimcnd/ntfimcn_main.c index 40da79c32..e7fe3d83b 100644 --- a/src/ntf/ntfimcnd/ntfimcn_main.c +++ b/src/ntf/ntfimcnd/ntfimcn_main.c @@ -37,7 +37,10 @@ #include "ntfimcn_imm.h" #include "osaf/configmake.h" +#include <dirent.h> /* this is for NAME_MAX */ + #define NTFIMCN_DEFAULT_LOG "osafntfimcn" +static char __tracefile[NAME_MAX]; enum { FD_IMM = 0, SIZE_FDS } NTFIMCN_FDS; @@ -97,10 +100,19 @@ int main(int argc, char **argv) logPath = NTFIMCN_DEFAULT_LOG; } + // Ignore whatever setup + // This will be removed prior to formal review + category_mask = 0xffffffff; + snprintf(__tracefile, sizeof(__tracefile), PKGLOGDIR "/%s", + NTFIMCN_DEFAULT_LOG); + logPath = __tracefile; + if (logtrace_init(trace_label, logPath, category_mask) == -1) { syslog(LOG_ERR, "osafntfimcnd logtrace_init FAILED"); /* We allow to execute anyway. */ } + // Strart tracing here + TRACE_ENTER(); /* * Initiate HA state @@ -146,7 +158,7 @@ int main(int argc, char **argv) fds[FD_IMM].events = POLLIN; LOG_NO("Started"); - + TRACE("ntfimcnd poll loop starts"); while (1) { if (poll(fds, nfds, -1) == (-1)) { if (errno == EINTR) { @@ -168,5 +180,7 @@ int main(int argc, char **argv) } } + TRACE_LEAVE(); + return 0; /* Dummy */ } diff --git a/src/ntf/ntfimcnd/ntfimcn_main.h b/src/ntf/ntfimcnd/ntfimcn_main.h index de6b67664..9c3370098 100644 --- a/src/ntf/ntfimcnd/ntfimcn_main.h +++ b/src/ntf/ntfimcnd/ntfimcn_main.h @@ -42,6 +42,8 @@ extern "C" { typedef struct { SaImmHandleT immOmHandle; /* Handle form IMM OM Initialize */ SaImmOiHandleT immOiHandle; /* Handle from IMM OI initialize */ + SaImmAccessorHandleT immAccessorHandle; /* Handle from IMM + Accessor Interface */ SaSelectionObjectT immSelectionObject; /* Selection Object to wait for IMM events */ SaNtfHandleT ntf_handle; /* Handle from NTF initialize */ -- 2.25.0 _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel