Added close socket and clean buffer to Downloader URIReader and InputHLS
This commit is contained in:
parent
503a9591c9
commit
12246581e6
3 changed files with 22 additions and 0 deletions
|
@ -87,6 +87,7 @@ namespace HTTP{
|
|||
if (!proxied || needSSL){
|
||||
if (!getSocket() || link.host != connectedHost || link.getPort() != connectedPort || needSSL != ssl){
|
||||
getSocket().close();
|
||||
getSocket().Received().clear();
|
||||
connectedHost = link.host;
|
||||
connectedPort = link.getPort();
|
||||
#ifdef SSL
|
||||
|
@ -102,6 +103,7 @@ namespace HTTP{
|
|||
}else{
|
||||
if (!getSocket() || proxyUrl.host != connectedHost || proxyUrl.getPort() != connectedPort || needSSL != ssl){
|
||||
getSocket().close();
|
||||
getSocket().Received().clear();
|
||||
connectedHost = proxyUrl.host;
|
||||
connectedPort = proxyUrl.getPort();
|
||||
getSocket().open(connectedHost, connectedPort, true);
|
||||
|
@ -195,6 +197,16 @@ namespace HTTP{
|
|||
// Data! Check if we can parse it...
|
||||
if (H.Read(getSocket())){
|
||||
H.headerOnly = false;
|
||||
|
||||
// If the return status code is invalid, close the socket, wipe all buffers, and return false
|
||||
if(!getStatusCode()){
|
||||
H.headerOnly = false;
|
||||
getSocket().close();
|
||||
getSocket().Received().clear();
|
||||
H.Clean();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (shouldContinue()){
|
||||
if (maxRecursiveDepth == 0){
|
||||
FAIL_MSG("Maximum recursion depth reached");
|
||||
|
|
|
@ -107,6 +107,9 @@ namespace HTTP{
|
|||
if (!downer.head(myURI) || !downer.isOk()){
|
||||
FAIL_MSG("Error getting URI info for '%s': %" PRIu32 " %s", myURI.getUrl().c_str(),
|
||||
downer.getStatusCode(), downer.getStatusText().c_str());
|
||||
// Close the socket, and clean up the buffer
|
||||
downer.getSocket().close();
|
||||
downer.getSocket().Received().clear();
|
||||
if (!downer.isOk()){return false;}
|
||||
supportRangeRequest = false;
|
||||
totalSize = std::string::npos;
|
||||
|
@ -256,6 +259,8 @@ namespace HTTP{
|
|||
void URIReader::close(){
|
||||
// Close downloader socket if open
|
||||
downer.getSocket().close();
|
||||
downer.getSocket().Received().clear();
|
||||
downer.getHTTP().Clean();
|
||||
// Unmap file if mapped
|
||||
if (mapped){
|
||||
munmap(mapped, totalSize);
|
||||
|
|
|
@ -679,6 +679,11 @@ namespace Mist{
|
|||
break; // we have all tracks discovered, next playlist!
|
||||
}
|
||||
}while (!segDowner.atEnd());
|
||||
if (!segDowner.atEnd()){
|
||||
segDowner.close();
|
||||
tsStream.clear();
|
||||
}
|
||||
|
||||
if (prepidCounter < pidCounter){break;}// We're done reading this playlist!
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue