Abort aria2 if it could not setup any RPC server.

pull/1/head
Tatsuhiro Tsujikawa 2011-06-15 22:19:09 +09:00
parent fae5e143f0
commit c0d1e98133
1 changed files with 6 additions and 1 deletions

View File

@ -164,17 +164,22 @@ DownloadEngineFactory::newDownloadEngine
}
}
if(op->getAsBool(PREF_ENABLE_RPC)) {
bool ok = false;
static int families[] = { AF_INET, AF_INET6 };
size_t familiesLength = op->getAsBool(PREF_DISABLE_IPV6)?1:2;
for(size_t i = 0; i < familiesLength; ++i) {
HttpListenCommand* httpListenCommand =
new HttpListenCommand(e->newCUID(), e.get(), families[i]);
if(httpListenCommand->bindPort(op->getAsInt(PREF_RPC_LISTEN_PORT))){
e->addRoutineCommand(httpListenCommand);
e->addCommand(httpListenCommand);
ok = true;
} else {
delete httpListenCommand;
}
}
if(!ok) {
throw DL_ABORT_EX("Failed to setup RPC server.");
}
}
return e;
}