return result;
}
-void RMProcess()
+#ifdef WITH_PROCESS_EVENT
+static void compareAndApplyTimeout(uint32_t *nextEventTime,
+ uint64_t timeoutSec)
+{
+ uint32_t timeoutMs = timeoutSec * MS_PER_SEC;
+ if (timeoutMs < *nextEventTime)
+ {
+ *nextEventTime = timeoutMs;
+ }
+}
+
+void RMProcess(uint32_t *nextEventTime)
+#else // WITH_PROCESS_EVENT
+void RMProcess(void)
+#endif // !WITH_PROCESS_EVENT
{
if (!g_isRMInitialized)
{
result = RMSendNotificationToAll(payload);
RMPFreePayload(payload);
RM_VERIFY_SUCCESS(result, OC_STACK_OK);
+#ifdef WITH_PROCESS_EVENT
+ compareAndApplyTimeout(nextEventTime, GATEWAY_ALIVE_TIMEOUT);
+#endif // WITH_PROCESS_EVENT
+ }
+#ifdef WITH_PROCESS_EVENT
+ else
+ {
+ compareAndApplyTimeout(nextEventTime,
+ GATEWAY_ALIVE_TIMEOUT - (currentTime - g_aliveTime));
}
+#endif // WITH_PROCESS_EVENT
if (ROUTINGTABLE_VALIDATION_TIMEOUT <= currentTime - g_refreshTableTime)
{
g_refreshTableTime = currentTime;
g_isValidated = false;
u_linklist_free(&removedEntries);
+#ifdef WITH_PROCESS_EVENT
+ compareAndApplyTimeout(nextEventTime, ROUTINGTABLE_VALIDATION_TIMEOUT);
+#endif // WITH_PROCESS_EVENT
goto exit;
}
+#ifdef WITH_PROCESS_EVENT
+ else
+ {
+ compareAndApplyTimeout(nextEventTime,
+ ROUTINGTABLE_VALIDATION_TIMEOUT - (currentTime - g_refreshTableTime));
+ }
+#endif // WITH_PROCESS_EVENT
if (!g_isValidated && ROUTINGTABLE_REFRESH_TIMEOUT <= (currentTime - g_refreshTableTime))
{
g_isValidated = true;
RTMPrintTable(g_routingGatewayTable, g_routingEndpointTable);
u_linklist_free(&invalidInterfaces);
+#ifdef WITH_PROCESS_EVENT
+ compareAndApplyTimeout(nextEventTime, ROUTINGTABLE_REFRESH_TIMEOUT);
+#endif // WITH_PROCESS_EVENT
+ }
+#ifdef WITH_PROCESS_EVENT
+ else
+ {
+ compareAndApplyTimeout(nextEventTime,
+ ROUTINGTABLE_REFRESH_TIMEOUT - (currentTime - g_refreshTableTime));
}
+#endif // WITH_PROCESS_EVENT
exit:
return;