summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGavin Hurlbut <ghurlbut@mythtv.org>2010-12-06 08:32:53 (GMT)
committer Gavin Hurlbut <ghurlbut@mythtv.org>2010-12-06 09:03:07 (GMT)
commitd5d1cc16c11ebb32e0c37ebdf51a25ff1f0bd051 (patch)
treead00849beb0cb88c3a560366c164ed395390d956
parent5e5908b4d6ca88ecf4892e0e853e6b2a78a0546e (diff)
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.
-rw-r--r--mythtv/libs/libmythupnp/httprequest.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/mythtv/libs/libmythupnp/httprequest.cpp b/mythtv/libs/libmythupnp/httprequest.cpp
index 74ed31c..766d04e 100644
--- a/mythtv/libs/libmythupnp/httprequest.cpp
+++ b/mythtv/libs/libmythupnp/httprequest.cpp
@@ -522,6 +522,8 @@ qint64 HTTPRequest::SendFile( QFile &file, qint64 llStart, qint64 llBytes )
}
else
{
+ qint64 llSent = 0;
+
do
{
// SSIZE_MAX should work in kernels 2.6.16 and later.
@@ -531,12 +533,18 @@ qint64 HTTPRequest::SendFile( QFile &file, qint64 llStart, qint64 llBytes )
getSocketHandle(), fd, &offset,
(size_t) ((llBytes > INT_MAX) ? INT_MAX : llBytes));
- llBytes -= ( offset - llStart );
- VERBOSE(VB_UPNP, QString("SendResponseFile : --- "
- "size = %1, offset = %2, sent = %3")
- .arg(llBytes).arg(offset).arg(sent));
+ if (sent >= 0)
+ {
+ llBytes -= sent;
+ llSent += sent;
+ VERBOSE(VB_UPNP, QString("SendResponseFile : --- "
+ "size = %1, offset = %2, sent = %3")
+ .arg(llBytes).arg(offset).arg(sent));
+ }
}
while (( sent >= 0 ) && ( llBytes > 0 ));
+
+ sent = llSent;
}
#endif