mirror of https://github.com/aria2/aria2
Move setSignalHander to Util::setGlobalSignalHandler:
* src/TorrentRequestInfo.cc: setSignalHander -> Util::setGlobalSignalHandler * src/main.cc (setSignalHander): Removed. (main): setSignalHander -> Util::setGlobalSignalHandler * src/Util.h (setGlobalSignalHandler): New function. * src/Util.cc (setGlobalSignalHandler): New function. * src/UrlRequestInfo.cc: setSignalHander -> Util::setGlobalSignalHandlerpull/1/head
parent
3c1ecc7d30
commit
9b48e350c6
23
ChangeLog
23
ChangeLog
|
@ -1,7 +1,7 @@
|
|||
2006-11-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Introduce new preference PREF_BT_TIMEOUT. This is the timeout value
|
||||
for BitTorrent download.
|
||||
for BitTorrent download:
|
||||
|
||||
* src/PeerAbstractCommand.cc
|
||||
(PeerAbstractCommand): PREF_TIMEOUT -> PREF_BT_TIMEOUT
|
||||
|
@ -11,16 +11,29 @@
|
|||
Removed timeoutSpecified. TODO: Add --bt-timeout command line option.
|
||||
* src/TorrentRequestInfo.cc
|
||||
(timeoutSpecified): Removed.
|
||||
(torrentHandler): Removed timeoutSpecified and the change of timeout
|
||||
value.
|
||||
(torrentHandler): Removed timeoutSpecified and the adjustment of
|
||||
timeout value.
|
||||
* src/prefs.h
|
||||
(PREF_BT_TIMEOUT): New definition.
|
||||
|
||||
Delete unused variables.
|
||||
Delete unused variables:
|
||||
|
||||
* src/TorrentRequestInfo.cc
|
||||
(requestInfo): Removed.
|
||||
|
||||
|
||||
Move setSignalHander to Util::setGlobalSignalHandler:
|
||||
|
||||
* src/TorrentRequestInfo.cc:
|
||||
setSignalHander -> Util::setGlobalSignalHandler
|
||||
* src/main.cc
|
||||
(setSignalHander): Removed.
|
||||
(main): setSignalHander -> Util::setGlobalSignalHandler
|
||||
* src/Util.h
|
||||
(setGlobalSignalHandler): New function.
|
||||
* src/Util.cc
|
||||
(setGlobalSignalHandler): New function.
|
||||
* src/UrlRequestInfo.cc:
|
||||
setSignalHander -> Util::setGlobalSignalHandler
|
||||
|
||||
2006-11-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
|
|
1
TODO
1
TODO
|
@ -19,3 +19,4 @@
|
|||
* Rewrite Util::countBit
|
||||
* Add Turkish translation.
|
||||
* Add the message like "you can resume the transfer by invoking aria2 again" when the download stops.
|
||||
* Add --bt-timeout command line option.
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "BtRegistry.h"
|
||||
#include "DefaultBtContext.h"
|
||||
|
||||
extern void setSignalHander(int signal, void (*handler)(int), int flags);
|
||||
extern volatile sig_atomic_t btHaltRequested;
|
||||
|
||||
void torrentHandler(int signal) {
|
||||
|
@ -61,8 +60,8 @@ RequestInfos TorrentRequestInfo::execute() {
|
|||
op,
|
||||
targetFiles));
|
||||
|
||||
setSignalHander(SIGINT, torrentHandler, SA_RESETHAND);
|
||||
setSignalHander(SIGTERM, torrentHandler, SA_RESETHAND);
|
||||
Util::setGlobalSignalHandler(SIGINT, torrentHandler, SA_RESETHAND);
|
||||
Util::setGlobalSignalHandler(SIGTERM, torrentHandler, SA_RESETHAND);
|
||||
|
||||
try {
|
||||
e->run();
|
||||
|
@ -74,8 +73,8 @@ RequestInfos TorrentRequestInfo::execute() {
|
|||
fail = true;
|
||||
delete ex;
|
||||
}
|
||||
setSignalHander(SIGINT, SIG_DFL, 0);
|
||||
setSignalHander(SIGTERM, SIG_DFL, 0);
|
||||
Util::setGlobalSignalHandler(SIGINT, SIG_DFL, 0);
|
||||
Util::setGlobalSignalHandler(SIGTERM, SIG_DFL, 0);
|
||||
|
||||
return RequestInfos();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "prefs.h"
|
||||
#include "DownloadEngineFactory.h"
|
||||
|
||||
extern void setSignalHander(int signal, void (*handler)(int), int flags);
|
||||
extern volatile sig_atomic_t haltRequested;
|
||||
|
||||
void UrlRequestInfo::adjustRequestSize(Requests& requests,
|
||||
|
@ -122,8 +121,8 @@ RequestInfos UrlRequestInfo::execute() {
|
|||
|
||||
SharedHandle<ConsoleDownloadEngine> e(DownloadEngineFactory::newConsoleEngine(op, requests, reserved));
|
||||
|
||||
setSignalHander(SIGINT, handler, 0);
|
||||
setSignalHander(SIGTERM, handler, 0);
|
||||
Util::setGlobalSignalHandler(SIGINT, handler, 0);
|
||||
Util::setGlobalSignalHandler(SIGTERM, handler, 0);
|
||||
|
||||
RequestInfo* next = 0;
|
||||
try {
|
||||
|
@ -150,8 +149,8 @@ RequestInfos UrlRequestInfo::execute() {
|
|||
if(next) {
|
||||
nextReqInfos.push_front(next);
|
||||
}
|
||||
setSignalHander(SIGINT, SIG_DFL, 0);
|
||||
setSignalHander(SIGTERM, SIG_DFL, 0);
|
||||
Util::setGlobalSignalHandler(SIGINT, SIG_DFL, 0);
|
||||
Util::setGlobalSignalHandler(SIGTERM, SIG_DFL, 0);
|
||||
|
||||
return nextReqInfos;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
string Util::itos(int value, bool comma) {
|
||||
string str = llitos(value, comma);
|
||||
|
@ -599,3 +600,11 @@ bool Util::isNumbersAndDotsNotation(const string& name) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Util::setGlobalSignalHandler(int signal, void (*handler)(int), int flags) {
|
||||
struct sigaction sigact;
|
||||
sigact.sa_handler = handler;
|
||||
sigact.sa_flags = flags;
|
||||
sigemptyset(&sigact.sa_mask);
|
||||
sigaction(signal, &sigact, NULL);
|
||||
}
|
||||
|
|
|
@ -126,6 +126,8 @@ public:
|
|||
static string toLower(const string& src);
|
||||
|
||||
static bool isNumbersAndDotsNotation(const string& name);
|
||||
|
||||
static void setGlobalSignalHandler(int signal, void (*handler)(int), int flags);
|
||||
};
|
||||
|
||||
#endif // _D_UTIL_H_
|
||||
|
|
10
src/main.cc
10
src/main.cc
|
@ -72,14 +72,6 @@ extern int optind, opterr, optopt;
|
|||
|
||||
using namespace std;
|
||||
|
||||
void setSignalHander(int signal, void (*handler)(int), int flags) {
|
||||
struct sigaction sigact;
|
||||
sigact.sa_handler = handler;
|
||||
sigact.sa_flags = flags;
|
||||
sigemptyset(&sigact.sa_mask);
|
||||
sigaction(signal, &sigact, NULL);
|
||||
}
|
||||
|
||||
void showVersion() {
|
||||
cout << PACKAGE << _(" version ") << PACKAGE_VERSION << endl;
|
||||
cout << "**Configuration**" << endl;
|
||||
|
@ -732,7 +724,7 @@ int main(int argc, char* argv[]) {
|
|||
logger->info("%s %s", PACKAGE, PACKAGE_VERSION);
|
||||
logger->info("Logging started.");
|
||||
|
||||
setSignalHander(SIGPIPE, SIG_IGN, 0);
|
||||
Util::setGlobalSignalHandler(SIGPIPE, SIG_IGN, 0);
|
||||
|
||||
RequestInfo* firstReqInfo = 0;
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
|
|
Loading…
Reference in New Issue