static void clMsgEventCallbackFunc(ClEventSubscriptionIdT subscriptionId, ClEventHandleT eventHandle, ClSizeT eventDataSize) { ClRcT rc; ClCpmEventNodePayLoadT nodePayload = {{0}}; rc = clCpmEventPayLoadExtract(eventHandle, eventDataSize, CL_CPM_NODE_EVENT, (void *)&nodePayload); if(rc != CL_OK) { clLogError("EVT", "Cbk", "Failed to get event payload data. error code [0x%x].", rc); goto error_out; } if(nodePayload.operation != CL_CPM_NODE_DEPARTURE) goto out; clLogDebug("EVT", "Cbk", "Node [0x%x] is going down. Message queues are going to be failed over.", nodePayload.nodeIocAddress); if(nodePayload.nodeIocAddress == gLocalAddress) { CL_OSAL_MUTEX_LOCK(&gFinBlockMutex); rc = clMsgFinBlockStatusSet(MSG_MOVE_FIN_BLOCKED); CL_OSAL_MUTEX_UNLOCK(&gFinBlockMutex); if(rc != CL_OK) clLogError("EVT", "Cbk", "Failed at block the message finalize on this node. error code [0x%x].", rc); } error_out: out: clEventFree(eventHandle); return; }
static ClRcT clPubsTriggerEvent(ClEoLibIdT libId, ClWaterMarkIdT wmId, ClUint32T wmValue, ClEoWaterMarkFlagT wmFlag) { ClRcT rc = CL_OK; ClEventIdT eventId = 0; SaNameT publisherName = {sizeof(CL_EVENT_PUBLISHER_NAME)-1, CL_EVENT_PUBLISHER_NAME}; ClEventPatternT patterns[5] = {{0}}; ClEventPatternArrayT patternArray = { 0, CL_SIZEOF_ARRAY(patterns), patterns }; rc = clEventAllocate(gPubsEventInfo.channelHandle, &gPubsEventInfo.eventHandle); if(CL_OK != rc) { clOsalPrintf("clEventAllocate() failed [%#X]\n",rc); goto failure; } patterns[0].patternSize = strlen(CL_EO_NAME); patterns[0].pPattern = (ClUint8T *)CL_EO_NAME; patterns[1].patternSize = sizeof(libId); patterns[1].pPattern = (ClUint8T *)&libId; patterns[2].patternSize = sizeof(wmId); patterns[2].pPattern = (ClUint8T *)&wmId; patterns[3].patternSize = sizeof(wmFlag); patterns[3].pPattern = (ClUint8T *)&wmFlag; patterns[4].patternSize = sizeof(wmValue); patterns[4].pPattern = (ClUint8T *)(&wmValue); rc = clEventAttributesSet(gPubsEventInfo.eventHandle, &patternArray, CL_EVENT_HIGHEST_PRIORITY, 0, &publisherName); if(CL_OK != rc) { clOsalPrintf("clEventAttributesSet() failed [%#X]\n",rc); goto event_allocated; } rc = clEventPublish(gPubsEventInfo.eventHandle, "Event Payload passed in endian neutral way", sizeof("Event Payload passed in endian neutral way."), &eventId); if(CL_OK != rc) { clOsalPrintf("clEventPublish() failed [%#X]\n",rc); goto event_allocated; } event_allocated: rc = clEventFree(gPubsEventInfo.eventHandle); if(CL_OK != rc) { clOsalPrintf("clEventFree() failed [%#X]\n",rc); } failure: return rc; }
static void clSubEoEventWaterMarkCb( ClEventSubscriptionIdT subscriptionId, ClEventHandleT eventHandle, ClSizeT eventDataSize ) { ClRcT rc = CL_OK; ClEventPriorityT priority = 0; ClTimeT retentionTime = 0; ClNameT publisherName = { 0 }; ClEventIdT eventId = 0; ClEventPatternArrayT patternArray = { 0 }; ClTimeT publishTime = 0; ClPtrT pCookie = NULL; ClPtrT pEventData = NULL; ClUint8T *pEventPayload = NULL; /* * Allocate memory for the event payload. */ pEventData = clHeapAllocate(eventDataSize); if (pEventData == NULL) { clOsalPrintf("Allocation for event data failed. rc[%#X]\n", rc); goto failure; } /* * Fetch the event payload. NOTE that there is a bug in the SAF spec B.01.01 * allowing the application to pass a pointer and expecting the * clEventDataGet() to return the allocated memory. This is not possible as * the parameter pEventData is a single pointer so the memory allocated by * the callee can't be returned to the caller. */ rc = clEventDataGet (eventHandle, pEventData, &eventDataSize); if (rc != CL_OK) { clOsalPrintf("Event Data Get failed. rc[%#X]\n", rc); goto failure; } pEventPayload = pEventData; /* * Fetch the cookie specified during subscribe. */ rc = clEventCookieGet(eventHandle, &pCookie); if (rc != CL_OK) { clOsalPrintf("Event Cookie Get failed. rc[%#X]\n", rc); goto failure; } /* * Fetch the attributes of the event. */ rc = clEventAttributesGet(eventHandle, &patternArray, &priority, &retentionTime, &publisherName, &publishTime, &eventId); if (rc != CL_OK) { clOsalPrintf("Event Attributes Get failed. rc[%#X]\n", rc); goto failure; } /* * Free the allocated Event */ rc = clEventFree(eventHandle); clOsalPrintf("-------------------------------------------------------\n"); clOsalPrintf("!!!!!!!!!!!!!!! Event Delivery Callback !!!!!!!!!!!!!!!\n"); clOsalPrintf("-------------------------------------------------------\n"); clOsalPrintf(" Subscription ID : %#X\n", subscriptionId); clOsalPrintf(" Event Priority : %#X\n", priority); clOsalPrintf(" Publish Time : 0x%llX\n", publishTime); clOsalPrintf(" Retention Time : 0x%llX\n", retentionTime); clOsalPrintf(" Publisher Name : %.*s\n", publisherName.length, publisherName.value); clOsalPrintf(" EventID : %#X\n", eventId); clOsalPrintf(" Event Payload : %s\n", pEventPayload); clOsalPrintf(" Event Cookie : %s\n", (ClUint8T*)pCookie); clHeapFree(pEventPayload); // Release the memory allocated for the payload. /* * Display the Water Mark Details and Free the patterns. * Note that each pattern needs to be freed and then the * pattern array in that order. */ clOsalPrintf(" EO Name : %.*s\n", (ClInt32T)patternArray.pPatterns[0].patternSize, (ClCharT *)patternArray.pPatterns[0].pPattern); clHeapFree(patternArray.pPatterns[0].pPattern); clOsalPrintf(" Library ID : %#X\n", *(ClEoLibIdT *)patternArray.pPatterns[1].pPattern); clHeapFree(patternArray.pPatterns[1].pPattern); clOsalPrintf(" Water Mark ID : %#X\n", *(ClWaterMarkIdT *)patternArray.pPatterns[2].pPattern); clHeapFree(patternArray.pPatterns[2].pPattern); clOsalPrintf(" Water Mark Type : %s\n", (*(ClEoWaterMarkFlagT *)patternArray.pPatterns[3].pPattern == CL_WM_HIGH_LIMIT)? "HIGH" : "LOW"); clHeapFree(patternArray.pPatterns[3].pPattern); clOsalPrintf(" Water Mark Value : %u\n", *(ClUint32T *)patternArray.pPatterns[4].pPattern); clHeapFree(patternArray.pPatterns[4].pPattern); clHeapFree(patternArray.pPatterns); clOsalPrintf("-------------------------------------------------------\n"); failure: return; }