Code cleanup

pull/28/head
Tatsuhiro Tsujikawa 2012-09-07 21:45:36 +09:00
parent 763c7a0aa0
commit d0703a2f26
1 changed files with 19 additions and 18 deletions

View File

@ -112,33 +112,34 @@ bool TrackerWatcherCommand::execute() {
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, ex); A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, ex);
} }
} }
} else if(trackerRequestGroup_->getNumCommand() == 0 && } else if(trackerRequestGroup_->getNumCommand() == 0) {
trackerRequestGroup_->downloadFinished()){
// We really want to make sure that tracker request has finished // We really want to make sure that tracker request has finished
// by checking getNumCommand() == 0. Because we reset // by checking getNumCommand() == 0. Because we reset
// trackerRequestGroup_, if it is still used in other Command, we // trackerRequestGroup_, if it is still used in other Command, we
// will get Segmentation fault. // will get Segmentation fault.
try { if(trackerRequestGroup_->downloadFinished()) {
std::string trackerResponse = getTrackerResponse(trackerRequestGroup_); try {
std::string trackerResponse = getTrackerResponse(trackerRequestGroup_);
processTrackerResponse(trackerResponse); processTrackerResponse(trackerResponse);
btAnnounce_->announceSuccess(); btAnnounce_->announceSuccess();
btAnnounce_->resetAnnounce(); btAnnounce_->resetAnnounce();
} catch(RecoverableException& ex) { } catch(RecoverableException& ex) {
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, ex); A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, ex);
btAnnounce_->announceFailure(); btAnnounce_->announceFailure();
if(btAnnounce_->isAllAnnounceFailed()) {
btAnnounce_->resetAnnounce();
}
}
trackerRequestGroup_.reset();
} else {
// handle errors here
btAnnounce_->announceFailure(); // inside it, trackers = 0.
trackerRequestGroup_.reset();
if(btAnnounce_->isAllAnnounceFailed()) { if(btAnnounce_->isAllAnnounceFailed()) {
btAnnounce_->resetAnnounce(); btAnnounce_->resetAnnounce();
} }
} }
trackerRequestGroup_.reset();
} else if(trackerRequestGroup_->getNumCommand() == 0){
// handle errors here
btAnnounce_->announceFailure(); // inside it, trackers = 0.
trackerRequestGroup_.reset();
if(btAnnounce_->isAllAnnounceFailed()) {
btAnnounce_->resetAnnounce();
}
} }
e_->addCommand(this); e_->addCommand(this);
return false; return false;