2008-09-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Added convenient method RequestGroupMan::getOrCreateServerStat()
	* src/RequestGroupMan.cc
	* src/RequestGroupMan.h
pull/1/head
Tatsuhiro Tsujikawa 2008-09-14 14:25:16 +00:00
parent 0680ac5e5e
commit 72da43e47f
3 changed files with 23 additions and 8 deletions

View File

@ -1,3 +1,9 @@
2008-09-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added convenient method RequestGroupMan::getOrCreateServerStat()
* src/RequestGroupMan.cc
* src/RequestGroupMan.h
2008-09-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
If error event is received in epoll, then abort download immediately.

View File

@ -203,13 +203,8 @@ public:
continue;
}
SharedHandle<ServerStat> ss =
_requestGroupMan->findServerStat((*i)->getHostname(),
(*i)->getProtocol());
if(ss.isNull()) {
ss.reset(new ServerStat((*i)->getHostname(),
(*i)->getProtocol()));
_requestGroupMan->addServerStat(ss);
}
_requestGroupMan->getOrCreateServerStat((*i)->getHostname(),
(*i)->getProtocol());
ss->updateDownloadSpeed((*i)->getAvgDownloadSpeed());
}
}
@ -475,6 +470,18 @@ RequestGroupMan::findServerStat(const std::string& hostname,
return _serverStatMan->find(hostname, protocol);
}
SharedHandle<ServerStat>
RequestGroupMan::getOrCreateServerStat(const std::string& hostname,
const std::string& protocol)
{
SharedHandle<ServerStat> ss = findServerStat(hostname, protocol);
if(ss.isNull()) {
ss.reset(new ServerStat(hostname, protocol));
addServerStat(ss);
}
return ss;
}
bool RequestGroupMan::addServerStat(const SharedHandle<ServerStat>& serverStat)
{
return _serverStatMan->add(serverStat);

View File

@ -139,8 +139,10 @@ public:
SharedHandle<ServerStat> findServerStat(const std::string& hostname,
const std::string& protocol) const;
bool addServerStat(const SharedHandle<ServerStat>& serverStat);
SharedHandle<ServerStat> getOrCreateServerStat(const std::string& hostname,
const std::string& protocol);
bool addServerStat(const SharedHandle<ServerStat>& serverStat);
void updateServerStat();