ThreadData::~ThreadData() { if ( s != NULL ) { MSN_DebugLog( "Closing connection handle %08X", s ); Netlib_CloseHandle( s ); } if ( mIncomingBoundPort != NULL ) { Netlib_CloseHandle( mIncomingBoundPort ); } if ( mMsnFtp != NULL ) { delete mMsnFtp; mMsnFtp = NULL; } if ( hWaitEvent != INVALID_HANDLE_VALUE ) CloseHandle( hWaitEvent ); p2p_clearDormantSessions(); free( mJoinedContacts ); while (mFirstQueueItem != NULL) { TQueueItem* QI = mFirstQueueItem; mFirstQueueItem = mFirstQueueItem->next; free(QI); } }
void __cdecl CMsnProto::msn_keepAliveThread(void*) { bool keepFlag = true; hKeepAliveThreadEvt = CreateEvent(NULL, FALSE, FALSE, NULL); msnPingTimeout = 45; while (keepFlag) { switch (WaitForSingleObject(hKeepAliveThreadEvt, msnPingTimeout * 1000)) { case WAIT_TIMEOUT: keepFlag = msnNsThread != NULL; if (usingGateway) msnPingTimeout = 45; else { msnPingTimeout = 20; keepFlag = keepFlag && (lastMsgId?msnNsThread->sendPacketPayload("PNG", "CON", "\bLast-Msg-Id: %I64u\r\n\r\n", lastMsgId): (msnRegistration?msnNsThread->sendPacketPayload("PNG", "CON", "\b\r\n"): msnNsThread->sendPacket("PNG", "CON 0"))); } #ifdef OBSOLETE p2p_clearDormantSessions(); #endif if (hHttpsConnection && (clock() - mHttpsTS) > 60 * CLOCKS_PER_SEC) { HANDLE hConn = hHttpsConnection; hHttpsConnection = NULL; Netlib_Shutdown(hConn); } if (mStatusMsgTS && (clock() - mStatusMsgTS) > 60 * CLOCKS_PER_SEC) { mStatusMsgTS = 0; ForkThread(&CMsnProto::msn_storeProfileThread, NULL); } if (MyOptions.netId!=NETID_SKYPE && MSN_RefreshOAuthTokens(true)) ForkThread(&CMsnProto::msn_refreshOAuthThread, msnNsThread); break; case WAIT_OBJECT_0: keepFlag = msnPingTimeout > 0; break; default: keepFlag = false; break; } } CloseHandle(hKeepAliveThreadEvt); hKeepAliveThreadEvt = NULL; debugLogA("Closing keep-alive thread"); }