Skip to content

Commit

Permalink
Fix bug that signal handler does not work with libaria2
Browse files Browse the repository at this point in the history
This commit fixes the bug that signal handler does not work with
libaria2 when aria2::RUN_ONCE is passed to aria2::run().
  • Loading branch information
tatsuhiro-t committed Oct 31, 2017
1 parent 450b4f4 commit 85b102a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/DownloadEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,22 @@ void executeCommand(std::deque<std::unique_ptr<Command>>& commands,
namespace {
class GlobalHaltRequestedFinalizer {
public:
GlobalHaltRequestedFinalizer() = default;
~GlobalHaltRequestedFinalizer() { global::globalHaltRequested = 5; }
GlobalHaltRequestedFinalizer(bool oneshot) : oneshot_(oneshot) {}
~GlobalHaltRequestedFinalizer()
{
if (!oneshot_) {
global::globalHaltRequested = 5;
}
}

private:
bool oneshot_;
};
} // namespace

int DownloadEngine::run(bool oneshot)
{
GlobalHaltRequestedFinalizer ghrf;
GlobalHaltRequestedFinalizer ghrf(oneshot);
while (!commands_.empty() || !routineCommands_.empty()) {
if (!commands_.empty()) {
waitData();
Expand Down

0 comments on commit 85b102a

Please sign in to comment.