Commit 2a6547a9 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Jean-Baptiste Kempf

dash: Removing useless and potentially harmful recursion.

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 88dc675a
...@@ -87,14 +87,27 @@ void HTTPConnectionManager::closeAllConnections () ...@@ -87,14 +87,27 @@ void HTTPConnectionManager::closeAllConnections ()
this->chunkMap.clear(); this->chunkMap.clear();
} }
int HTTPConnectionManager::read (Chunk *chunk, void *p_buffer, size_t len)
int HTTPConnectionManager::read( Chunk *chunk, void *p_buffer, size_t len )
{ {
if(this->chunkMap.find(chunk) != this->chunkMap.end()) if(this->chunkMap.find(chunk) == this->chunkMap.end())
{ {
mtime_t start = mdate(); this->bytesReadChunk = 0;
int ret = this->chunkMap[chunk]->read(p_buffer, len); this->timeSecChunk = 0;
mtime_t end = mdate();
if ( this->initConnection( chunk ) == NULL )
return -1;
}
mtime_t start = mdate();
int ret = this->chunkMap[chunk]->read(p_buffer, len);
mtime_t end = mdate();
std::cout << "ret: " << ret << std::endl;
if( ret <= 0 )
this->closeConnection( chunk );
else
{
double time = ((double)(end - start)) / 1000000; double time = ((double)(end - start)) / 1000000;
this->bytesReadSession += ret; this->bytesReadSession += ret;
...@@ -116,30 +129,18 @@ int HTTPConnectionManager::read (Chunk *chun ...@@ -116,30 +129,18 @@ int HTTPConnectionManager::read (Chunk *chun
this->bpsLastChunk = 0; this->bpsLastChunk = 0;
this->notify(); this->notify();
if(ret <= 0)
this->closeConnection(chunk);
return ret;
} }
else return ret;
{ }
this->bytesReadChunk = 0;
this->timeSecChunk = 0;
int HTTPConnectionManager::peek (Chunk *chunk, const uint8_t **pp_peek, size_t i_peek)
{
if(this->chunkMap.find(chunk) == this->chunkMap.end())
{
if ( this->initConnection(chunk) == NULL ) if ( this->initConnection(chunk) == NULL )
return -1; return -1;
return this->read(chunk, p_buffer, len);
} }
} return this->chunkMap[chunk]->peek(pp_peek, i_peek);
int HTTPConnectionManager::peek (Chunk *chunk, const uint8_t **pp_peek, size_t i_peek)
{
if(this->chunkMap.find(chunk) != this->chunkMap.end())
return this->chunkMap[chunk]->peek(pp_peek, i_peek);
if ( this->initConnection(chunk) == NULL )
return -1;
return this->peek(chunk, pp_peek, i_peek);
} }
IHTTPConnection* HTTPConnectionManager::initConnection(Chunk *chunk) IHTTPConnection* HTTPConnectionManager::initConnection(Chunk *chunk)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment