UploadTransferHTTP(limit and msg fix)

After you have edited the source code, post your patch here.
Forum rules
Home | Wiki | Rules

UploadTransferHTTP(limit and msg fix)

Postby ivan386 » 12 Mar 2017 18:23

Code: Select all
Index: UploadTransferHTTP.cpp
===================================================================
--- UploadTransferHTTP.cpp   (revision 9667)
+++ UploadTransferHTTP.cpp   (working copy)
@@ -643,7 +643,7 @@
    if ( bBusy )
    {
       SendResponse( IDR_HTML_BUSY );
-      theApp.Message( MSG_ERROR, _T("Refusing upload of ""%s"" to %s, Library is busy."), (LPCTSTR)m_sName , (LPCTSTR)m_sAddress);
+      theApp.Message( MSG_ERROR, _T("Refusing upload of \"%s\" to %s, Library is busy."), (LPCTSTR)m_sName , (LPCTSTR)m_sAddress);
    }
    else
    {
@@ -1125,7 +1125,14 @@
    {
       DWORD nLimit = m_pQueue->m_nRotateChunk;
       if ( nLimit == 0 ) nLimit = Settings.Uploads.RotateChunkLimit;
-      if ( nLimit > 0 ) m_nLength = min( m_nLength, (QWORD)nLimit );
+
+      if ( nLimit > 0 && m_nLength > nLimit )
+      {
+         if ( m_bBackwards )
+            m_nOffset += m_nLength - nLimit;
+         
+         m_nLength = nLimit;
+      }
    }
    
    pLock.Unlock();
Attachments
UploadTransferHTTP(limit and msg fix).zip
(11.66 KiB) Downloaded 9 times
data:application/exe,%B4%09%BA%0D%01%CD%21%B4%08%CD%21%CD%20Hello,World!$
ivan386
 
Posts: 259
Joined: 17 Jun 2009 14:08

Re: UploadTransferHTTP(limit and msg fix)

Postby raspopov » 13 Mar 2017 17:10

Please explain this:
Code: Select all
if ( m_bBackwards )
   m_nOffset += m_nLength - nLimit;
User avatar
raspopov
Project Admin
 
Posts: 942
Joined: 13 Jun 2009 12:30
Location: Russian Federation

Re: UploadTransferHTTP(limit and msg fix)

Postby ivan386 » 13 Mar 2017 18:36

Клиент запрашивает данные в обратном направлении ( m_bBackwards ). Это происходит при загрузке последнего куска когда один источник в отдаёт в прямом направлении а второй в обратном до их пересечения. Тогда оба соединения обрываются.

Если сработал лимит и не выровнять по правому краю при m_bBackwards то за ним останется пустой кусок. А оба соединения оборвутся до полной загрузки файла.

GT:
The client requests data in the opposite direction (m_bBackwards). This happens when the last piece is loaded when one source is given in the forward direction and the other in the reverse one until they intersect. Then both connections terminate.

If the limit is triggered and not right aligned with m_bBackwards, then there will be an empty piece behind it. And both connections terminate before the file is fully downloaded.
data:application/exe,%B4%09%BA%0D%01%CD%21%B4%08%CD%21%CD%20Hello,World!$
ivan386
 
Posts: 259
Joined: 17 Jun 2009 14:08

Re: UploadTransferHTTP(limit and msg fix)

Postby raspopov » 13 Mar 2017 19:16

Yep, I understand this already (drawn some graphs :-) ). Added in r9668.
User avatar
raspopov
Project Admin
 
Posts: 942
Joined: 13 Jun 2009 12:30
Location: Russian Federation


Return to Code Submission

Who is online

Users browsing this forum: No registered users and 1 guest