mirror of https://github.com/aria2/aria2
Merge pull request #1053 from aria2/fix-libaria2-signal-handler
Fix bug that signal handler does not work with libaria2pull/1057/head
commit
d508e41198
|
@ -150,14 +150,22 @@ void executeCommand(std::deque<std::unique_ptr<Command>>& commands,
|
||||||
namespace {
|
namespace {
|
||||||
class GlobalHaltRequestedFinalizer {
|
class GlobalHaltRequestedFinalizer {
|
||||||
public:
|
public:
|
||||||
GlobalHaltRequestedFinalizer() = default;
|
GlobalHaltRequestedFinalizer(bool oneshot) : oneshot_(oneshot) {}
|
||||||
~GlobalHaltRequestedFinalizer() { global::globalHaltRequested = 5; }
|
~GlobalHaltRequestedFinalizer()
|
||||||
|
{
|
||||||
|
if (!oneshot_) {
|
||||||
|
global::globalHaltRequested = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool oneshot_;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int DownloadEngine::run(bool oneshot)
|
int DownloadEngine::run(bool oneshot)
|
||||||
{
|
{
|
||||||
GlobalHaltRequestedFinalizer ghrf;
|
GlobalHaltRequestedFinalizer ghrf(oneshot);
|
||||||
while (!commands_.empty() || !routineCommands_.empty()) {
|
while (!commands_.empty() || !routineCommands_.empty()) {
|
||||||
if (!commands_.empty()) {
|
if (!commands_.empty()) {
|
||||||
waitData();
|
waitData();
|
||||||
|
|
Loading…
Reference in New Issue