mirror of https://github.com/aria2/aria2
* src/TrackerInitCommand.cc (TrackerInitCommand): Added a "key"
parameter to a tracker request. * src/TorrentMan.cc (readFileEntryFromMetaInfoFile): Bug fix. * src/TrackerWatcherCommand.cc (execute): Call req->resetTryCount(). * src/main.cc (setSignalHander): New function. (main): Added a handler for SIGTERM. (handler): Updated message. (torrentHandler): Updated message.pull/1/head
parent
28a82bfa4a
commit
dcc225a145
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2006-04-17 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
* src/TrackerInitCommand.cc (TrackerInitCommand): Added a "key"
|
||||
parameter to a tracker request.
|
||||
|
||||
* src/TorrentMan.cc (readFileEntryFromMetaInfoFile): Bug fix.
|
||||
|
||||
* src/TrackerWatcherCommand.cc (execute): Call req->resetTryCount().
|
||||
|
||||
* src/main.cc (setSignalHander): New function.
|
||||
(main): Added a handler for SIGTERM.
|
||||
(handler): Updated message.
|
||||
(torrentHandler): Updated message.
|
||||
|
||||
|
||||
2006-04-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
* src/TorrentConsoleDownloadEngine.cc
|
||||
|
|
4
TODO
4
TODO
|
@ -13,11 +13,9 @@
|
|||
* Distinguish seeder from leecher
|
||||
|
||||
0.4.0 release
|
||||
* Add selective downloading mode
|
||||
* try to use ftruncate to allocate file.
|
||||
* test all download mode
|
||||
* Add loggerfactory
|
||||
* Add SIGTERM signal handler
|
||||
* add log message when download completes
|
||||
|
||||
0.4.1 release
|
||||
* Add port command-line option
|
||||
|
|
|
@ -427,9 +427,11 @@ FileEntries TorrentMan::readFileEntryFromMetaInfoFile(const string& metaInfoFile
|
|||
Dictionary* topDic = (Dictionary*)MetaFileUtil::parseMetaFile(metaInfoFile);
|
||||
const Dictionary* infoDic = (const Dictionary*)topDic->get("info");
|
||||
FileEntries fileEntries;
|
||||
Directory* topDir;
|
||||
Directory* topDir = NULL;
|
||||
readFileEntry(fileEntries, &topDir, infoDic, metaInfoFile);
|
||||
delete topDir;
|
||||
if(topDir != NULL) {
|
||||
delete topDir;
|
||||
}
|
||||
return fileEntries;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,8 @@ bool TrackerInitCommand::execute() {
|
|||
"downloaded="+Util::llitos(e->torrentMan->getSessionDownloadLength())+"&"+
|
||||
"left="+(e->torrentMan->getTotalLength()-e->torrentMan->getDownloadLength() <= 0
|
||||
? "0" : Util::llitos(e->torrentMan->getTotalLength()-e->torrentMan->getDownloadLength()))+"&"+
|
||||
"compact=1";
|
||||
"compact=1"+"&"+
|
||||
"key="+e->torrentMan->peerId;
|
||||
if(!event.empty()) {
|
||||
url += string("&")+"event="+event;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ TrackerWatcherCommand::TrackerWatcherCommand(int cuid, Request* req,
|
|||
TrackerWatcherCommand::~TrackerWatcherCommand() {}
|
||||
|
||||
bool TrackerWatcherCommand::execute() {
|
||||
req->resetTryCount();
|
||||
Command* command = new TrackerInitCommand(e->torrentMan->getNewCuid(),
|
||||
req,
|
||||
e);
|
||||
|
|
40
src/main.cc
40
src/main.cc
|
@ -71,6 +71,14 @@ void printDownloadAbortMessage() {
|
|||
printf(_("\nThe download was not complete because of errors. Check the log.\n"));
|
||||
}
|
||||
|
||||
void setSignalHander(int signal, void (*handler)(int)) {
|
||||
struct sigaction sigact;
|
||||
sigact.sa_handler = handler;
|
||||
sigact.sa_flags = 0;
|
||||
sigemptyset(&sigact.sa_mask);
|
||||
sigaction(signal, &sigact, NULL);
|
||||
}
|
||||
|
||||
void clearRequest(Request* req) {
|
||||
delete(req);
|
||||
}
|
||||
|
@ -79,16 +87,19 @@ DownloadEngine* e;
|
|||
TorrentDownloadEngine* te;
|
||||
|
||||
void handler(int signal) {
|
||||
cout << _("\nSIGINT signal received.") << endl;
|
||||
printf(_("\nstopping application...\n"));
|
||||
fflush(stdout);
|
||||
e->segmentMan->save();
|
||||
if(e->diskWriter != NULL) {
|
||||
e->diskWriter->closeFile();
|
||||
}
|
||||
printf("done\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void torrentHandler(int signal) {
|
||||
cout << _("\nSIGINT signal received.") << endl;
|
||||
printf(_("\nstopping application...\n"));
|
||||
fflush(stdout);
|
||||
if(te->torrentMan->diskAdaptor != NULL) {
|
||||
te->torrentMan->diskAdaptor->closeFile();
|
||||
}
|
||||
|
@ -99,7 +110,7 @@ void torrentHandler(int signal) {
|
|||
} else {
|
||||
te->torrentMan->save();
|
||||
}
|
||||
|
||||
printf("done\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -533,21 +544,14 @@ int main(int argc, char* argv[]) {
|
|||
SegmentSplitter* splitter = new SplitSlowestSegmentSplitter();
|
||||
splitter->setMinSegmentSize(op->getAsLLInt(PREF_MIN_SEGMENT_SIZE));
|
||||
|
||||
struct sigaction sigactIgn;
|
||||
sigactIgn.sa_handler = SIG_IGN;
|
||||
sigactIgn.sa_flags = 0;
|
||||
sigemptyset(&sigactIgn.sa_mask);
|
||||
sigaction(SIGPIPE, &sigactIgn, NULL);
|
||||
setSignalHander(SIGPIPE, SIG_IGN);
|
||||
|
||||
bool readyToTorrentMode = false;
|
||||
string downloadedTorrentFile;
|
||||
if(torrentFile.empty()) {
|
||||
struct sigaction sigact;
|
||||
sigact.sa_handler = handler;
|
||||
sigact.sa_flags = 0;
|
||||
sigemptyset(&sigact.sa_mask);
|
||||
sigaction(SIGINT, &sigact, NULL);
|
||||
|
||||
setSignalHander(SIGINT, handler);
|
||||
setSignalHander(SIGTERM, handler);
|
||||
|
||||
splitter->logger = logger;
|
||||
e = new ConsoleDownloadEngine();
|
||||
e->logger = logger;
|
||||
|
@ -590,11 +594,9 @@ int main(int argc, char* argv[]) {
|
|||
if(!torrentFile.empty() || followTorrent && readyToTorrentMode) {
|
||||
try {
|
||||
//op->put(PREF_MAX_TRIES, "0");
|
||||
struct sigaction sigact;
|
||||
sigact.sa_handler = torrentHandler;
|
||||
sigact.sa_flags = 0;
|
||||
sigemptyset(&sigact.sa_mask);
|
||||
sigaction(SIGINT, &sigact, NULL);
|
||||
setSignalHander(SIGINT, torrentHandler);
|
||||
setSignalHander(SIGTERM, torrentHandler);
|
||||
|
||||
Request* req = new Request();
|
||||
req->isTorrent = true;
|
||||
req->setTrackerEvent(Request::STARTED);
|
||||
|
|
Loading…
Reference in New Issue