void processFdbEntriesForAging() { SWSS_LOG_ENTER(); if (!g_recursive_mutex.try_lock()) { return; } SWSS_LOG_INFO("fdb infos to process: %zu", g_fdb_info_set.size()); uint32_t current = (uint32_t)time(NULL); // find aged fdb entries for (auto it = g_fdb_info_set.begin(); it != g_fdb_info_set.end();) { sai_attribute_t attr; attr.id = SAI_SWITCH_ATTR_FDB_AGING_TIME; sai_status_t status = vs_generic_get(SAI_OBJECT_TYPE_SWITCH, it->fdb_entry.switch_id, 1, &attr); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_WARN("failed to get FDB aging time for switch %s", sai_serialize_object_id(it->fdb_entry.switch_id).c_str()); ++it; continue; } uint32_t aging_time = attr.value.u32; if (aging_time == 0) { // aging is disabled ++it; continue; } if ((current - it->timestamp) >= aging_time) { fdb_info_t fi = *it; processFdbInfo(fi, SAI_FDB_EVENT_AGED); it = g_fdb_info_set.erase(it); } else { ++it; } } g_recursive_mutex.unlock(); }
// Read the Wiimote once void Update(int _WiimoteNumber) { // Try to get a lock and return without doing anything if we fail // This avoids deadlocks when adding a Wiimote during continuous scan if(!g_refresh_lock.try_lock()) return; if (g_wiimotes[_WiimoteNumber]) g_wiimotes[_WiimoteNumber]->Update(); // Wiimote::Update() may remove the Wiimote if it was disconnected. if (!g_wiimotes[_WiimoteNumber]) { Host_ConnectWiimote(_WiimoteNumber, false); } g_refresh_lock.unlock(); }