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