Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix file streaming to stay working past 4G

The previous logic would loop, and remove 2G from llBytes the first time
through the loop (correctly), but remove 4G from llBytes the second time
through the loop (very incorrectly).  This causes a UPnP client, etc to
abruptly stop after 4G if the file size is between 4G and 6G, and 2G early for
file size of 6G to 8G, and so on.

I simplified the logic to work correctly in my testing.
  • Loading branch information...
commit 011ffd5134d5e6e7baace071a4ebc70d6bdd3fb0 1 parent ecbbcf8
Gavin Hurlbut authored

Showing 1 changed file with 12 additions and 4 deletions. Show diff stats Hide diff stats

  1. 16  mythtv/libs/libmythupnp/httprequest.cpp
16  mythtv/libs/libmythupnp/httprequest.cpp
@@ -522,6 +522,8 @@ qint64 HTTPRequest::SendFile( QFile &file, qint64 llStart, qint64 llBytes )
522 522
     } 
523 523
     else 
524 524
     { 
  525
+        qint64     llSent = 0;
  526
+
525 527
         do 
526 528
         { 
527 529
             // SSIZE_MAX should work in kernels 2.6.16 and later. 
@@ -531,12 +533,18 @@ qint64 HTTPRequest::SendFile( QFile &file, qint64 llStart, qint64 llBytes )
531 533
                 getSocketHandle(), fd, &offset, 
532 534
                 (size_t) ((llBytes > INT_MAX) ? INT_MAX : llBytes)); 
533 535
   
534  
-            llBytes  -= ( offset - llStart ); 
535  
-            VERBOSE(VB_UPNP, QString("SendResponseFile : --- " 
536  
-            "size = %1, offset = %2, sent = %3") 
537  
-            .arg(llBytes).arg(offset).arg(sent)); 
  536
+            if (sent >= 0)
  537
+            {
  538
+                llBytes -= sent; 
  539
+                llSent  += sent;
  540
+                VERBOSE(VB_UPNP, QString("SendResponseFile : --- " 
  541
+                        "size = %1, offset = %2, sent = %3") 
  542
+                        .arg(llBytes).arg(offset).arg(sent)); 
  543
+            }
538 544
         } 
539 545
         while (( sent >= 0 ) && ( llBytes > 0 )); 
  546
+
  547
+        sent = llSent;
540 548
     } 
541 549
 
542 550
 #endif

0 notes on commit 011ffd5

Please sign in to comment.
Something went wrong with that request. Please try again.