void UnicastUdpTransport::afterChangePersistency(ndn::nfd::FacePersistency oldPersistency) { if (getPersistency() == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND && m_idleTimeout > time::nanoseconds::zero()) { scheduleClosureWhenIdle(); } else { m_closeIfIdleEvent.cancel(); setExpirationTime(time::steady_clock::TimePoint::max()); } }
void UnicastUdpTransport::scheduleClosureWhenIdle() { m_closeIfIdleEvent = scheduler::schedule(m_idleTimeout, [this] { if (!hasBeenUsedRecently()) { NFD_LOG_FACE_INFO("Closing due to inactivity"); this->close(); } else { resetRecentUsage(); scheduleClosureWhenIdle(); } }); setExpirationTime(time::steady_clock::now() + m_idleTimeout); }
static int LsLuaShmSetHelper(lua_State *L, LsShmHash *pShared, int numElem, const char *keyName) { /* NOTE: elements 3 = value, 4 = expTime, 5 = flags */ ls_luashm_t *p_Val = NULL; const char *p_string; size_t len; int valueType = LsLuaApi::type(L, 3); switch (valueType) { case LUA_TNIL: p_Val = LsLuaShmSetval(pShared, keyName, ls_luashm_nil, NULL, 0); LsLuaApi::pushboolean(L, 1); LsLuaApi::pushnil(L); LsLuaApi::pushboolean(L, 0); return 3; case LUA_TNUMBER: double myDouble; long myLong; p_string = LsLuaApi::tolstring(L, 3, &len); if (memchr(p_string, '.', len)) { myDouble = LsLuaApi::tonumber(L, 3); p_Val = LsLuaShmSetval(pShared, keyName, ls_luashm_double, &myDouble, sizeof(myDouble)); } else { myLong = LsLuaApi::tonumber(L, 3); p_Val = LsLuaShmSetval(pShared, keyName, ls_luashm_long, &myLong, sizeof(myLong)); } break; case LUA_TBOOLEAN: char myBool; if (LsLuaApi::toboolean(L, 3)) myBool = 1; else myBool = 0; p_Val = LsLuaShmSetval(pShared, keyName, ls_luashm_boolean, &myBool, sizeof(myBool)); break; case LUA_TSTRING: p_string = LsLuaApi::tolstring(L, 3, &len); p_Val = LsLuaShmSetval(pShared, keyName, ls_luashm_string, p_string, len); break; case LUA_TNONE: case LUA_TTABLE: case LUA_TFUNCTION: case LUA_TUSERDATA: case LUA_TTHREAD: case LUA_TLIGHTUSERDATA: default: LsLuaApi::pushboolean(L, 0); LsLuaApi::pushstring(L, "bad value type"); LsLuaApi::pushboolean(L, 0); return 3; } if (p_Val) { if (numElem > 3) { lua_Number tValue = LsLuaApi::tonumber(L, 4); setExpirationTime(p_Val, tValue); if (numElem > 4) p_Val->m_iFlags = LsLuaApi::tointeger(L, 5); } LsLuaApi::pushboolean(L, 1); LsLuaApi::pushnil(L); LsLuaApi::pushboolean(L, 0); return 3; } LsLuaApi::pushboolean(L, 0); LsLuaApi::pushstring(L, "bad hashkey"); LsLuaApi::pushboolean(L, 0); return 3; }