Skip to content

Commit 89b1bbb

Browse files
committed
Test to fix some connect timeouts #2
1 parent f394dc7 commit 89b1bbb

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

MTA10/core/CConnectManager.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ bool CConnectManager::Connect ( const char* szHost, unsigned short usPort, const
116116
if ( !CCore::GetSingleton ().CheckDiskSpace () )
117117
return false;
118118

119-
// Test: Fix some timeouts by trying a tcp connection
120-
pNet->GetHTTPDownloadManager ( EDownloadMode::CORE_UPDATER )->QueueFile ( m_strHost.c_str(), NULL, 0, "", 0, true, NULL, NULL, false, 1, 2000 );
121-
122119
// Set our packet handler
123120
pNet->RegisterPacketHandler ( CConnectManager::StaticProcessPacket );
124121

@@ -133,6 +130,7 @@ bool CConnectManager::Connect ( const char* szHost, unsigned short usPort, const
133130

134131
m_bIsConnecting = true;
135132
m_tConnectStarted = time ( NULL );
133+
m_bHasSentTcpRequest = false;
136134

137135
// Load server password
138136
if ( m_strPassword.empty () )
@@ -250,6 +248,17 @@ void CConnectManager::DoPulse ( void )
250248
}
251249
}
252250

251+
if ( !m_bHasSentTcpRequest )
252+
{
253+
if ( time ( NULL ) >= m_tConnectStarted + 2 )
254+
{
255+
// Handle possible IP rejection by proving we exist with a TCP connection
256+
g_pCore->GetNetwork()->GetHTTPDownloadManager( EDownloadMode::CORE_UPDATER )->QueueFile( m_strHost.c_str(), NULL, 0, "", 0, true, NULL, NULL, false, 1, 2000 );
257+
m_bHasSentTcpRequest = true;
258+
AddReportLog( 9401, SString( "ConnectManager sent TCP connection request to %s", m_strHost.c_str() ) );
259+
}
260+
}
261+
253262
// Time to timeout the connection?
254263
if ( time ( NULL ) >= m_tConnectStarted + 8 )
255264
{

MTA10/core/CConnectManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class CConnectManager
5555
bool m_bSave;
5656
bool m_bForceInternalHTTPServer;
5757
time_t m_tConnectStarted;
58+
bool m_bHasSentTcpRequest;
5859

5960
GUI_CALLBACK* m_pOnCancelClick;
6061

0 commit comments

Comments
 (0)