//-------------------------------------------------------------------------------------------------- static void WatchdogHandleExpiry ( le_timer_Ref_t timerRef ///< [IN] The reference to the expired timer ) { char appName[LIMIT_MAX_APP_NAME_BYTES]; pid_t procId = (intptr_t)le_timer_GetContextPtr(timerRef); WatchdogObj_t* expiredDog = LookupClientWatchdogPtrById(procId); if (expiredDog != NULL) { uid_t appId = expiredDog->appId; if (LE_OK == user_GetAppName(appId, appName, sizeof(appName) )) { LE_CRIT("app %s, proc %d timed out", appName, procId); } else { LE_CRIT("app %d, proc %d timed out", appId, procId); } DeleteWatchdog(procId); le_sup_wdog_WatchdogTimedOut(appId, procId); } else { LE_CRIT("Processing watchdog timeout for proc %d but watchdog already freed.", procId); } }
//-------------------------------------------------------------------------------------------------- static void OnTransactionTimeout ( le_timer_Ref_t timerRef ///< The timer that expired. ) //-------------------------------------------------------------------------------------------------- { // Extract the iterator reference out of the timer object. Then perform a sanity check to make // sure everything is going to plan. ni_IteratorRef_t iteratorRef = (ni_IteratorRef_t)le_timer_GetContextPtr(timerRef); LE_ASSERT(iteratorRef->timerRef == timerRef); // For clearer message reporting, figure out if this is a read or write transaction. char* iterTypePtr = "Read"; if (ni_IsWriteable(iteratorRef)) { iterTypePtr = "Write"; } if (iteratorRef->isTerminated) { LE_DEBUG("Previously terminated iterator, <%p> timed out.", iteratorRef); return; } // Report the failure in the log, and close the client session. Once the session is closed all // of that user's resources within the configTree will be naturally cleaned up. LE_EMERG("%s transaction <%p> timer expired, for user %s, <%d>.", iterTypePtr, iteratorRef->reference, tu_GetUserName(iteratorRef->userRef), tu_GetUserId(iteratorRef->userRef)); tu_TerminateConfigClient(iteratorRef->sessionRef, "Transaction timeout."); }
static void mqttClient_pingExpiryHndlr(le_timer_Ref_t timer) { mqttClient_t* clientData = le_timer_GetContextPtr(timer); int32_t rc = LE_OK; LE_ASSERT(clientData); int len = MQTTSerialize_pingreq(clientData->session.tx.buf, sizeof(clientData->session.tx.buf)); if (len < 0) { LE_ERROR("MQTTSerialize_pingreq() failed(%d)", len); goto cleanup; } LE_DEBUG("<--- PING"); rc = mqttClient_write(clientData, len); if (rc) { LE_ERROR("mqttClient_write() failed(%d)", rc); goto cleanup; } cleanup: return; }
static void mqttClient_connExpiryHndlr(le_timer_Ref_t timer) { mqttClient_t* clientData = le_timer_GetContextPtr(timer); int32_t rc = LE_OK; LE_ASSERT(clientData); rc = mqttClient_close(clientData); if (rc) { LE_ERROR("mqttClient_close() failed(%d)", rc); goto cleanup; } LE_DEBUG("<--- reconnect"); rc = mqttClient_connect(clientData); if (rc) { LE_ERROR("mqttClient_connect() failed(%d)", rc); goto cleanup; } cleanup: return; }
//-------------------------------------------------------------------------------------------------- static void SampleTimer ( le_timer_Ref_t timerRef ///< This timer has expired ) { static int variableIntOneCount = 0; le_avdata_AssetInstanceRef_t instOneRef; instOneRef = (le_avdata_AssetInstanceRef_t) le_timer_GetContextPtr(timerRef); le_avdata_SetInt(instOneRef, "variableIntOne", variableIntOneCount++); }
static void mqttClient_cmdExpiryHndlr(le_timer_Ref_t timer) { mqttClient_t* clientData = le_timer_GetContextPtr(timer); int32_t rc = LE_OK; LE_ASSERT(clientData); if (clientData->session.cmdRetries < MQTT_CLIENT_MAX_SEND_RETRIES) { if (clientData->session.sock == MQTT_CLIENT_INVALID_SOCKET) { LE_DEBUG("<--- reconnect"); rc = mqttClient_connect(clientData); if (rc) { LE_ERROR("mqttClient_connect() failed(%d)", rc); goto cleanup; } } else { LE_DEBUG("<--- resend CMD(%u)", clientData->session.cmdRetries++); rc = mqttClient_write(clientData, clientData->session.cmdLen); if (rc) { LE_ERROR("mqttClient_write() failed(%d)", rc); goto cleanup; } } } else { LE_ERROR("maximum retries reached(%u)", MQTT_CLIENT_MAX_SEND_RETRIES); goto cleanup; } cleanup: return; }