mirror of https://github.com/aria2/aria2
Abort aria2 if it could not setup any RPC server.
parent
fae5e143f0
commit
c0d1e98133
|
@ -164,17 +164,22 @@ DownloadEngineFactory::newDownloadEngine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(op->getAsBool(PREF_ENABLE_RPC)) {
|
if(op->getAsBool(PREF_ENABLE_RPC)) {
|
||||||
|
bool ok = false;
|
||||||
static int families[] = { AF_INET, AF_INET6 };
|
static int families[] = { AF_INET, AF_INET6 };
|
||||||
size_t familiesLength = op->getAsBool(PREF_DISABLE_IPV6)?1:2;
|
size_t familiesLength = op->getAsBool(PREF_DISABLE_IPV6)?1:2;
|
||||||
for(size_t i = 0; i < familiesLength; ++i) {
|
for(size_t i = 0; i < familiesLength; ++i) {
|
||||||
HttpListenCommand* httpListenCommand =
|
HttpListenCommand* httpListenCommand =
|
||||||
new HttpListenCommand(e->newCUID(), e.get(), families[i]);
|
new HttpListenCommand(e->newCUID(), e.get(), families[i]);
|
||||||
if(httpListenCommand->bindPort(op->getAsInt(PREF_RPC_LISTEN_PORT))){
|
if(httpListenCommand->bindPort(op->getAsInt(PREF_RPC_LISTEN_PORT))){
|
||||||
e->addRoutineCommand(httpListenCommand);
|
e->addCommand(httpListenCommand);
|
||||||
|
ok = true;
|
||||||
} else {
|
} else {
|
||||||
delete httpListenCommand;
|
delete httpListenCommand;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!ok) {
|
||||||
|
throw DL_ABORT_EX("Failed to setup RPC server.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue