2010-02-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Fixed the bug that aria2 doesn't handle return value if error
	occurred before download begins.
	* src/MultiUrlRequestInfo.cc
	* src/main.cc
pull/1/head
Tatsuhiro Tsujikawa 2010-02-12 13:53:52 +00:00
parent 1a04d2913e
commit 2097b5e29a
3 changed files with 82 additions and 72 deletions

View File

@ -1,3 +1,10 @@
2010-02-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that aria2 doesn't handle return value if error
occurred before download begins.
* src/MultiUrlRequestInfo.cc
* src/main.cc
2010-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> 2010-02-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed SegmentManFactory class. Removed SegmentManFactory class.

View File

@ -190,6 +190,9 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
} }
} }
} catch(RecoverableException& e) { } catch(RecoverableException& e) {
if(returnValue == downloadresultcode::FINISHED) {
returnValue = downloadresultcode::UNKNOWN_ERROR;
}
_logger->error(EX_EXCEPTION_CAUGHT, e); _logger->error(EX_EXCEPTION_CAUGHT, e);
} }
#ifdef SIGHUP #ifdef SIGHUP

View File

@ -195,105 +195,105 @@ downloadresultcode::RESULT main(int argc, char* argv[])
SocketCore::useSelect(); SocketCore::useSelect();
} }
downloadresultcode::RESULT exitStatus = downloadresultcode::FINISHED; downloadresultcode::RESULT exitStatus = downloadresultcode::FINISHED;
try {
Logger* logger = LogFactory::getInstance(); Logger* logger = LogFactory::getInstance();
logger->info("<<--- --- --- ---"); logger->info("<<--- --- --- ---");
logger->info(" --- --- --- ---"); logger->info(" --- --- --- ---");
logger->info(" --- --- --- --->>"); logger->info(" --- --- --- --->>");
logger->info("%s %s %s", PACKAGE, PACKAGE_VERSION, TARGET); logger->info("%s %s %s", PACKAGE, PACKAGE_VERSION, TARGET);
logger->info(MSG_LOGGING_STARTED); logger->info(MSG_LOGGING_STARTED);
#ifdef ENABLE_MESSAGE_DIGEST #ifdef ENABLE_MESSAGE_DIGEST
MessageDigestHelper::staticSHA1DigestInit(); MessageDigestHelper::staticSHA1DigestInit();
#endif // ENABLE_MESSAGE_DIGEST #endif // ENABLE_MESSAGE_DIGEST
if(op->getAsBool(PREF_DISABLE_IPV6)) { if(op->getAsBool(PREF_DISABLE_IPV6)) {
SocketCore::setProtocolFamily(AF_INET); SocketCore::setProtocolFamily(AF_INET);
// Get rid of AI_ADDRCONFIG. It causes name resolution error // Get rid of AI_ADDRCONFIG. It causes name resolution error
// when none of network interface has IPv4 address. // when none of network interface has IPv4 address.
setDefaultAIFlags(0); setDefaultAIFlags(0);
} }
// Bind interface // Bind interface
if(!op->get(PREF_INTERFACE).empty()) { if(!op->get(PREF_INTERFACE).empty()) {
std::string iface = op->get(PREF_INTERFACE); std::string iface = op->get(PREF_INTERFACE);
SocketCore::bindAddress(iface); SocketCore::bindAddress(iface);
} }
#ifdef SIGPIPE #ifdef SIGPIPE
util::setGlobalSignalHandler(SIGPIPE, SIG_IGN, 0); util::setGlobalSignalHandler(SIGPIPE, SIG_IGN, 0);
#endif #endif
#ifdef SIGCHLD #ifdef SIGCHLD
// Avoid to create zombie process when forked child processes are // Avoid to create zombie process when forked child processes are
// died. // died.
util::setGlobalSignalHandler(SIGCHLD, SIG_IGN, 0); util::setGlobalSignalHandler(SIGCHLD, SIG_IGN, 0);
#endif // SIGCHILD #endif // SIGCHILD
std::deque<SharedHandle<RequestGroup> > requestGroups; std::deque<SharedHandle<RequestGroup> > requestGroups;
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
if(!op->blank(PREF_TORRENT_FILE)) { if(!op->blank(PREF_TORRENT_FILE)) {
if(op->get(PREF_SHOW_FILES) == V_TRUE) {
showTorrentFile(op->get(PREF_TORRENT_FILE));
return exitStatus;
} else {
createRequestGroupForBitTorrent(requestGroups, op, args);
}
}
else
#endif // ENABLE_BITTORRENT
#ifdef ENABLE_METALINK
if(!op->blank(PREF_METALINK_FILE)) {
if(op->get(PREF_SHOW_FILES) == V_TRUE) { if(op->get(PREF_SHOW_FILES) == V_TRUE) {
showTorrentFile(op->get(PREF_TORRENT_FILE)); showMetalinkFile(op->get(PREF_METALINK_FILE), op);
return exitStatus; return exitStatus;
} else { } else {
createRequestGroupForBitTorrent(requestGroups, op, args); createRequestGroupForMetalink(requestGroups, op);
} }
} }
else else
#endif // ENABLE_BITTORRENT
#ifdef ENABLE_METALINK
if(!op->blank(PREF_METALINK_FILE)) {
if(op->get(PREF_SHOW_FILES) == V_TRUE) {
showMetalinkFile(op->get(PREF_METALINK_FILE), op);
return exitStatus;
} else {
createRequestGroupForMetalink(requestGroups, op);
}
}
else
#endif // ENABLE_METALINK #endif // ENABLE_METALINK
if(!op->blank(PREF_INPUT_FILE)) { if(!op->blank(PREF_INPUT_FILE)) {
createRequestGroupForUriList(requestGroups, op); createRequestGroupForUriList(requestGroups, op);
#if defined ENABLE_BITTORRENT || defined ENABLE_METALINK #if defined ENABLE_BITTORRENT || defined ENABLE_METALINK
} else if(op->get(PREF_SHOW_FILES) == V_TRUE) { } else if(op->get(PREF_SHOW_FILES) == V_TRUE) {
showFiles(args, op); showFiles(args, op);
return exitStatus; return exitStatus;
#endif // ENABLE_METALINK || ENABLE_METALINK #endif // ENABLE_METALINK || ENABLE_METALINK
} else { } else {
createRequestGroupForUri(requestGroups, op, args); createRequestGroupForUri(requestGroups, op, args);
} }
// Remove option values which is only valid for URIs specified in // Remove option values which is only valid for URIs specified in
// command-line. If they are left, because op is used as a // command-line. If they are left, because op is used as a
// template for new RequestGroup(such as created in XML-RPC // template for new RequestGroup(such as created in XML-RPC
// command), they causes unintentional effect. // command), they causes unintentional effect.
op->remove(PREF_OUT); op->remove(PREF_OUT);
op->remove(PREF_FORCE_SEQUENTIAL); op->remove(PREF_FORCE_SEQUENTIAL);
op->remove(PREF_INPUT_FILE); op->remove(PREF_INPUT_FILE);
op->remove(PREF_INDEX_OUT); op->remove(PREF_INDEX_OUT);
op->remove(PREF_SELECT_FILE); op->remove(PREF_SELECT_FILE);
if( if(
#ifdef ENABLE_XML_RPC #ifdef ENABLE_XML_RPC
!op->getAsBool(PREF_ENABLE_XML_RPC) && !op->getAsBool(PREF_ENABLE_XML_RPC) &&
#endif // ENABLE_XML_RPC #endif // ENABLE_XML_RPC
requestGroups.empty()) { requestGroups.empty()) {
std::cout << MSG_NO_FILES_TO_DOWNLOAD << std::endl; std::cout << MSG_NO_FILES_TO_DOWNLOAD << std::endl;
} else { } else {
exitStatus = MultiUrlRequestInfo(requestGroups, op, getStatCalc(op), exitStatus = MultiUrlRequestInfo(requestGroups, op, getStatCalc(op),
getSummaryOut(op)).execute(); getSummaryOut(op)).execute();
}
} catch(Exception& ex) {
std::cerr << EX_EXCEPTION_CAUGHT << "\n" << ex.stackTrace() << std::endl;
exitStatus = downloadresultcode::UNKNOWN_ERROR;
} }
LogFactory::release();
return exitStatus; return exitStatus;
} }
} // namespace aria2 } // namespace aria2
int main(int argc, char* argv[]) { int main(int argc, char* argv[])
aria2::Platform platform; {
aria2::downloadresultcode::RESULT r;
aria2::downloadresultcode::RESULT r = aria2::main(argc, argv); try {
aria2::Platform platform;
r = aria2::main(argc, argv);
} catch(aria2::Exception& ex) {
std::cerr << EX_EXCEPTION_CAUGHT << "\n" << ex.stackTrace() << std::endl;
r = aria2::downloadresultcode::UNKNOWN_ERROR;
}
return r; return r;
} }