Example #1
0
void DllLibCurlGlobal::CheckIdle()
{
  /* avoid locking section here, to avoid stalling gfx thread on loads*/
  if(g_curlReferences == 0)
    return;
  CSingleLock lock(m_critSection);
  /* 20 seconds idle time before closing handle */
  const unsigned int idletime = 30000;

  VEC_CURLSESSIONS::iterator it = m_sessions.begin();
  while(it != m_sessions.end())
  {
    if( !it->m_busy && it->m_idletimestamp + idletime < CTimeUtils::GetTimeMS())
    {
      CLog::Log(LOGINFO, "%s - Closing session to %s ://%s (easy=%p, multi=%p)\n", __FUNCTION__, it->m_protocol.c_str(), it->m_hostname.c_str(), (void*)it->m_easy, (void*)it->m_multi);

      // It's important to clean up multi *before* cleaning up easy, because the multi cleanup
      // code accesses stuff in the easy's structure.
      if(it->m_multi)
        multi_cleanup(it->m_multi);
      if(it->m_easy)
        easy_cleanup(it->m_easy);

      Unload();

      it = m_sessions.erase(it);
      continue;
    }
    it++;
  }
  /* check if we should unload the dll */
  if(g_curlReferences == 1 && CTimeUtils::GetTimeMS() - g_curlTimeout > idletime)
    Unload();
}
Example #2
0
void DllLibCurlGlobal::CheckIdle()
{
  CSingleLock lock(m_critSection);
  /* 20 seconds idle time before closing handle */
  const unsigned int idletime = 30000;

  VEC_CURLSESSIONS::iterator it = m_sessions.begin();
  while (it != m_sessions.end())
  {
    if (!it->m_busy && (XbmcThreads::SystemClockMillis() - it->m_idletimestamp) > idletime)
    {
      CLog::Log(LOGINFO, "%s - Closing session to %s://%s (easy=%p, multi=%p)\n", __FUNCTION__,
                it->m_protocol.c_str(), it->m_hostname.c_str(), static_cast<void*>(it->m_easy),
                static_cast<void*>(it->m_multi));

      if (it->m_multi && it->m_easy)
        multi_remove_handle(it->m_multi, it->m_easy);
      if (it->m_easy)
        easy_cleanup(it->m_easy);
      if (it->m_multi)
        multi_cleanup(it->m_multi);

      it = m_sessions.erase(it);
      continue;
    }
    ++it;
  }
}