static int finalize() { static bool finalized = false; if (finalized) return 0; finalized = true; gstate.quit_activities(); #ifdef _WIN32 shutdown_idle_monitor(); #ifdef USE_WINSOCK if (WinsockCleanup()) { log_message_error("WinSockCleanup() failed"); return ERR_IO; } #endif cleanup_system_monitor(); #endif curl_cleanup(); #ifdef _DEBUG gstate.free_mem(); #endif diagnostics_finish(); gstate.cleanup_completed = true; return 0; }
static int finalize() { static bool finalized = false; if (finalized) return 0; finalized = true; gstate.quit_activities(); daily_xfer_history.write_state(); #ifdef _WIN32 shutdown_idle_monitor(); #ifdef USE_WINSOCK if (WinsockCleanup()) { log_message_error("Failed to cleanup the Windows Sockets interface"); return ERR_IO; } #endif cleanup_system_monitor(); #endif curl_cleanup(); gstate.free_mem(); gstate.cleanup_completed = true; return 0; }
void HXWinSockLib::UnLoad() { HXScopeLock lock((IHXMutex*)m_pLoadMutex); HX_ASSERT(m_hLib); if(m_hLib) { HXLOGL3(HXLOG_NETW, "HXWinSockLib::UnLoad(): usage count going to %lu", m_userCount - 1); HX_ASSERT(m_userCount > 0); if(0 == --m_userCount) { WinsockCleanup(); ::FreeLibrary(m_hLib); m_hLib = NULL; memset(&m_api, 0, sizeof(m_api)); HXLOGL3(HXLOG_NETW, "HXWinSockLib::UnLoad(): winsock unloaded"); } } }
HX_RESULT HXWinSockLib::WinsockInit() { HX_ASSERT(m_hLib); HX_ASSERT(0 == m_wsVersion); HX_RESULT hr = HXR_FAIL; // WinSock with IPv6 support appears to support 2.2, so we first ask for that hr = TryWinsockInit(2, 2); if(HXR_OK != hr) { hr = TryWinsockInit(1, 1); if(HXR_OK != hr) { HX_ASSERT(false); WinsockCleanup(); } } return hr; }