diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-05-04 23:56:19 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-05-04 23:56:19 +0900 |
| commit | ebfc5f55e50972520ead1fda7cabcdc494c61e3f (patch) | |
| tree | 28f38146a71ace546d67ac3742b9e91855aed515 /src/aria2api.cc | |
| parent | 7d55341fded7b88f528b62a5527f9df8bc3259d8 (diff) | |
Add SessionConfig to store per Session config
sessionConfigSetKeepRunning() was removed and SessionConfig has
keepRunning member instead. Signal handlers are now all prepared in
MultiUrlRequestGroup object. Setting SessionConfig.useSignalHandler to
false will avoid signal handler setup.
Diffstat (limited to 'src/aria2api.cc')
| -rw-r--r-- | src/aria2api.cc | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/aria2api.cc b/src/aria2api.cc index dcf5a007..30f0b02e 100644 --- a/src/aria2api.cc +++ b/src/aria2api.cc @@ -68,6 +68,11 @@ Session::Session(const KeyVals& options) Session::~Session() {} +SessionConfig::SessionConfig() + : keepRunning(false), + useSignalHandler(true) +{} + namespace { Platform* platform = 0; } // namespace @@ -91,7 +96,7 @@ int libraryDeinit() return 0; } -Session* sessionNew(const KeyVals& options) +Session* sessionNew(const KeyVals& options, const SessionConfig& config) { int rv; Session* session; @@ -101,6 +106,9 @@ Session* sessionNew(const KeyVals& options) return 0; } if(session->context->reqinfo) { + if(!config.useSignalHandler) { + session->context->reqinfo->setUseSignalHandler(false); + } rv = session->context->reqinfo->prepare(); if(rv != 0) { delete session; @@ -108,9 +116,11 @@ Session* sessionNew(const KeyVals& options) } const SharedHandle<DownloadEngine>& e = session->context->reqinfo->getDownloadEngine(); - // Add command to make aria2 keep event polling if - // sessionConfigSetKeepRunning is set to true. - e->addCommand(new KeepRunningCommand(e->newCUID(), e.get())); + if(config.keepRunning) { + e->getRequestGroupMan()->setKeepRunning(true); + // Add command to make aria2 keep event polling + e->addCommand(new KeepRunningCommand(e->newCUID(), e.get())); + } } else { delete session; session = 0; @@ -125,13 +135,6 @@ int sessionFinal(Session* session) return rv; } -int sessionConfigSetKeepRunning(Session* session, bool flag) -{ - session->context->reqinfo->getDownloadEngine()->getRequestGroupMan() - ->setKeepRunning(flag); - return 0; -} - int run(Session* session, RUN_MODE mode) { const SharedHandle<DownloadEngine>& e = |
