Skip to content

Commit

Permalink
Settings.Connection.Reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan386 committed Jul 19, 2019
1 parent ed24b1a commit c21751c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions shareaza/DownloadTransferHTTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void CDownloadTransferHTTP::Close( TRISTATE bKeepSource, DWORD nRetryAfter )
}
}

if ( m_bKeepAlive && ! ( m_bBusyFault || m_bBadResponse ) )
if ( Settings.Connection.Reuse && m_bKeepAlive && ! ( m_bBusyFault || m_bBadResponse ) )
GiveConnectionToNext();

CDownloadTransfer::Close( bKeepSource, nRetryAfter );
Expand All @@ -170,15 +170,17 @@ void CDownloadTransferHTTP::GiveConnectionToNext()
if ( pDownload == m_pDownload )
continue;

if ( pDownload->IsComplete() || pDownload->IsCompleted() )
if ( pDownload->IsComplete() || pDownload->IsCompleted() || pDownload->IsMoving() )
continue;

for ( POSITION posSource = pDownload->GetIterator(); posSource ; )
{
CDownloadSource* pSource = pDownload->GetNext( posSource );

if ( pSource->IsHTTPSource() && pSource->Equals(m_pSource)
&& !pSource->IsConnected() )
if ( pSource->m_nBusyCount == 0
&& pSource->IsHTTPSource()
&& !pSource->IsConnected()
&& pSource->Equals(m_pSource) )
{
if ( pSource->GetTransfer() )
continue;
Expand Down
1 change: 1 addition & 0 deletions shareaza/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ void CSettings::Load()
Add( _T("Connection"), _T("OutHost"), &Connection.OutHost );
Add( _T("Connection"), _T("RandomPort"), &Connection.RandomPort, false );
Add( _T("Connection"), _T("RequireForTransfers"), &Connection.RequireForTransfers, true );
Add( _T("Connection"), _T("Reuse"), &Connection.Reuse, false );
Add( _T("Connection"), _T("SendBuffer"), &Connection.SendBuffer, 8*Kilo, 1, 0, 64*Kilo, _T(" B") );
Add( _T("Connection"), _T("SkipWANIPSetup"), &Connection.SkipWANIPSetup, false );
Add( _T("Connection"), _T("SkipWANPPPSetup"), &Connection.SkipWANPPPSetup, false );
Expand Down
1 change: 1 addition & 0 deletions shareaza/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ class CSettings
DWORD TimeoutTraffic;
DWORD SendBuffer;
bool RequireForTransfers; // Only upload/download to connected networks
bool Reuse; // Give socket to another HTTP source with same ip:port
DWORD ConnectThrottle; // Delay between connection attempts to neighbors (milliseconds)
DWORD FailurePenalty; // Delay after connection failure (seconds, default = 300) (Neighbour connections)
DWORD FailureLimit; // Max allowed connection failures (default = 3) (Neighbour connections)
Expand Down

0 comments on commit c21751c

Please sign in to comment.