Commit 4e185356 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

dash: HTTPConnectionManager: Removing duplicate attribute.

Connection list was stored twice: once as a stand-alone list, once as a
map of Chunk/Connection.
parent 71dd06f6
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#endif #endif
#include "HTTPConnectionManager.h" #include "HTTPConnectionManager.h"
#include "mpd/Segment.h"
using namespace dash::http; using namespace dash::http;
using namespace dash::logic; using namespace dash::logic;
...@@ -48,14 +49,13 @@ HTTPConnectionManager::~HTTPConnectionManager () ...@@ -48,14 +49,13 @@ HTTPConnectionManager::~HTTPConnectionManager ()
bool HTTPConnectionManager::closeConnection( IHTTPConnection *con ) bool HTTPConnectionManager::closeConnection( IHTTPConnection *con )
{ {
for(std::vector<HTTPConnection *>::iterator it = this->connections.begin(); for(std::map<Chunk*, HTTPConnection *>::iterator it = this->chunkMap.begin();
it != this->connections.end(); ++it) it != this->chunkMap.end(); ++it)
{ {
if(*it == con) if( it->second == con )
{ {
(*it)->closeSocket(); delete con;
delete(*it); this->chunkMap.erase( it );
this->connections.erase(it);
return true; return true;
} }
} }
...@@ -73,20 +73,10 @@ bool HTTPConnectionManager::closeConnection( Chunk *chunk ) ...@@ -73,20 +73,10 @@ bool HTTPConnectionManager::closeConnection( Chunk *chunk )
void HTTPConnectionManager::closeAllConnections () void HTTPConnectionManager::closeAllConnections ()
{ {
for(std::vector<HTTPConnection *>::iterator it = this->connections.begin(); it != this->connections.end(); ++it)
{
(*it)->closeSocket();
delete(*it);
}
this->connections.clear();
this->urlMap.clear();
std::map<Chunk *, HTTPConnection *>::iterator it; std::map<Chunk *, HTTPConnection *>::iterator it;
for(it = this->chunkMap.begin(); it != this->chunkMap.end(); ++it) for(it = this->chunkMap.begin(); it != this->chunkMap.end(); ++it)
{ delete(it->second);
delete(it->first);
}
this->chunkMap.clear(); this->chunkMap.clear();
} }
...@@ -150,7 +140,6 @@ IHTTPConnection* HTTPConnectionManager::initConnection(Chunk *chunk) ...@@ -150,7 +140,6 @@ IHTTPConnection* HTTPConnectionManager::initConnection(Chunk *chunk)
HTTPConnection *con = new HTTPConnection(chunk->getUrl(), this->stream); HTTPConnection *con = new HTTPConnection(chunk->getUrl(), this->stream);
if ( con->init() == false ) if ( con->init() == false )
return NULL; return NULL;
this->connections.push_back(con);
this->chunkMap[chunk] = con; this->chunkMap[chunk] = con;
this->chunkCount++; this->chunkCount++;
return con; return con;
......
...@@ -56,7 +56,6 @@ namespace dash ...@@ -56,7 +56,6 @@ namespace dash
void notify (); void notify ();
private: private:
std::vector<HTTPConnection *> connections;
std::map<Chunk *, HTTPConnection *> chunkMap; std::map<Chunk *, HTTPConnection *> chunkMap;
std::map<std::string, HTTPConnection *> urlMap; std::map<std::string, HTTPConnection *> urlMap;
std::vector<dash::logic::IDownloadRateObserver *> rateObservers; std::vector<dash::logic::IDownloadRateObserver *> rateObservers;
......
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