Skip to content

Commit

Permalink
Fix file streaming to stay working past 4G
Browse files Browse the repository at this point in the history
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
Beirdo committed Dec 6, 2010
1 parent ffc0865 commit e4080ec
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions mythtv/libs/libmythupnp/httprequest.cpp
Expand Up @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit e4080ec

Please sign in to comment.