summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-09-21 14:37:15 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-09-21 14:37:15 +0000
commitc973c83bacdd3dd001290069a8c8b325746ccd4b (patch)
treeaaf4eab7292b26257a942a377bbb3dc8df4ca4eb /src
parent8b8325cafcfecc8c32a4f49a48ee7cfcc68d450a (diff)
* src/prefs.h
(PREF_MAX_SPEED_LIMIT): Renamed as PREF_MAX_DOWNLOAD_LIMIT. (PREF_UPLOAD_LIMIT): Renamed as PREF_MAX_UPLOAD_LIMIT. * src/PeerInteractionCommand.cc (PeerInteractionCommand): Use PREF_MAX_UPLOAD_LIMIT. (receiveMessages): Use PREF_MAX_DOWNLOAD_LIMIT. * src/PeerInteraction.cc (sendMessages): Use PREF_MAX_UPLOAD_LIMIT. * src/main.cc (showUsage): Updated the description of "--lowest-speed-limit" option. Added the description of "--max-download-limit" option. Removed the description of "--upload-limit" option. Added the description of "--max-upload-limit" option. (main): Use PREF_MAX_UPLOAD_LIMIT, PREF_MAX_DOWNLOAD_LIMIT. Added "--max-download-limit" option and "--max-upload-limit" option. Added the warning message if "--upload-limit" option is used. * src/DownloadCommand.cc (executeInternal): Use PREF_MAX_DOWNLOAD_LIMIT.
Diffstat (limited to 'src')
-rw-r--r--src/DownloadCommand.cc2
-rw-r--r--src/PeerInteraction.cc2
-rw-r--r--src/PeerInteractionCommand.cc4
-rw-r--r--src/main.cc46
-rw-r--r--src/prefs.h4
5 files changed, 44 insertions, 14 deletions
diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc
index e1c0212b..636fc42f 100644
--- a/src/DownloadCommand.cc
+++ b/src/DownloadCommand.cc
@@ -44,7 +44,7 @@ DownloadCommand::~DownloadCommand() {
}
bool DownloadCommand::executeInternal(Segment& segment) {
- int maxSpeedLimit = e->option->getAsInt(PREF_MAX_SPEED_LIMIT);
+ int maxSpeedLimit = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
if(maxSpeedLimit > 0 &&
maxSpeedLimit < e->segmentMan->calculateDownloadSpeed()) {
usleep(1);
diff --git a/src/PeerInteraction.cc b/src/PeerInteraction.cc
index a755149e..68a82532 100644
--- a/src/PeerInteraction.cc
+++ b/src/PeerInteraction.cc
@@ -60,7 +60,7 @@ bool PeerInteraction::isSendingMessageInProgress() const {
void PeerInteraction::sendMessages() {
MessageQueue tempQueue;
- int uploadLimit = option->getAsInt(PREF_UPLOAD_LIMIT);
+ int uploadLimit = option->getAsInt(PREF_MAX_UPLOAD_LIMIT);
while(messageQueue.size() > 0) {
PeerMessageHandle msg = messageQueue.front();
messageQueue.pop_front();
diff --git a/src/PeerInteractionCommand.cc b/src/PeerInteractionCommand.cc
index 2adee58c..392d5756 100644
--- a/src/PeerInteractionCommand.cc
+++ b/src/PeerInteractionCommand.cc
@@ -46,7 +46,7 @@ PeerInteractionCommand::PeerInteractionCommand(int cuid,
}
peerInteraction = new PeerInteraction(cuid, peer, socket, e->option,
e->torrentMan);
- setUploadLimit(e->option->getAsInt(PREF_UPLOAD_LIMIT));
+ setUploadLimit(e->option->getAsInt(PREF_MAX_UPLOAD_LIMIT));
chokeUnchokeCount = 0;
haveCount = 0;
keepAliveCount = 0;
@@ -190,7 +190,7 @@ void PeerInteractionCommand::decideChoking() {
void PeerInteractionCommand::receiveMessages() {
for(int i = 0; i < 50; i++) {
- int maxSpeedLimit = e->option->getAsInt(PREF_MAX_SPEED_LIMIT);
+ int maxSpeedLimit = e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT);
if(maxSpeedLimit > 0) {
TransferStat stat = e->torrentMan->calculateStat();
if(maxSpeedLimit < stat.downloadSpeed) {
diff --git a/src/main.cc b/src/main.cc
index 259dc5ef..51b985d4 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -152,10 +152,14 @@ void showUsage() {
" Default: tunnel") << endl;
cout << _(" --lowest-speed-limit Close connection if download speed is lower than\n"
" or equal to this value. 0 means aria2 does not\n"
- " care lowest speed limit. You can use K or M in\n"
- " the same manner as in --min-segment-size option.\n"
+ " care lowest speed limit.\n"
+ " You can append K or M(1K = 1024, 1M = 1024K).\n"
+
" This option does not affect BitTorrent download.\n"
" Default: 0") << endl;
+ cout << _(" --max-download-limit Set max download speed. 0 means unrestricted.\n"
+ " You can append K or M(1K = 1024, 1M = 1024K).\n"
+ " Default: 0") << endl;
#ifdef ENABLE_BITTORRENT
cout << _(" -T, --torrent-file=TORRENT_FILE The file path to .torrent file.") << endl;
cout << _(" --follow-torrent=true|false Setting this option to false prevents aria2 to\n"
@@ -167,8 +171,9 @@ void showUsage() {
" mentioned in .torrent file.\n"
" Default: true") << endl;
cout << _(" --listen-port=PORT Set port number to listen to for peer connection.") << endl;
- cout << _(" --upload-limit=SPEED Set upload speed limit in KB/sec. aria2 tries to\n"
- " keep upload speed under SPEED. 0 means unlimited.") << endl;
+ cout << _(" --max-upload-limit Set max upload speed. 0 means unrestricted.\n"
+ " You can append K or M(1K = 1024, 1M = 1024K).\n"
+ " Default: 0") << endl;
cout << _(" --select-file=INDEX... Set file to download by specifing its index.\n"
" You can know file index through --show-files\n"
" option. Multiple indexes can be specified by using\n"
@@ -305,9 +310,9 @@ int main(int argc, char* argv[]) {
op->put(PREF_FTP_VIA_HTTP_PROXY, V_TUNNEL);
op->put(PREF_AUTO_SAVE_INTERVAL, "60");
op->put(PREF_DIRECT_FILE_MAPPING, V_TRUE);
- op->put(PREF_UPLOAD_LIMIT, "0");
op->put(PREF_LOWEST_SPEED_LIMIT, "0");
- op->put(PREF_MAX_SPEED_LIMIT, "0");
+ op->put(PREF_MAX_DOWNLOAD_LIMIT, "0");
+ op->put(PREF_MAX_UPLOAD_LIMIT, "0");
op->put(PREF_STARTUP_IDLE_TIME, "10");
while(1) {
int optIndex = 0;
@@ -336,6 +341,7 @@ int main(int argc, char* argv[]) {
{ "min-segment-size", required_argument, &lopt, 13 },
{ "http-proxy-method", required_argument, &lopt, 14 },
{ "lowest-speed-limit", required_argument, &lopt, 200 },
+ { "max-download-limit", required_argument, &lopt, 201 },
#ifdef ENABLE_BITTORRENT
{ "torrent-file", required_argument, NULL, 'T' },
{ "listen-port", required_argument, &lopt, 15 },
@@ -343,10 +349,12 @@ int main(int argc, char* argv[]) {
{ "show-files", no_argument, NULL, 'S' },
{ "no-preallocation", no_argument, &lopt, 18 },
{ "direct-file-mapping", required_argument, &lopt, 19 },
+ // TODO remove upload-limit.
{ "upload-limit", required_argument, &lopt, 20 },
{ "select-file", required_argument, &lopt, 21 },
{ "seed-time", required_argument, &lopt, 22 },
{ "seed-ratio", required_argument, &lopt, 23 },
+ { "max-upload-limit", required_argument, &lopt, 24 },
#endif // ENABLE_BITTORRENT
#ifdef ENABLE_METALINK
{ "metalink-file", required_argument, NULL, 'M' },
@@ -495,13 +503,16 @@ int main(int argc, char* argv[]) {
}
break;
case 20: {
+ cerr << "Warning: upload-limit will be deprecated in the future release.\n"
+ "Use max-upload-limit instead. Because there is a difference between them,\n"
+ "take a look at the description of max-upload-limit option." << endl;
int uploadSpeed = strtol(optarg, NULL, 10)*1024;
if(0 > uploadSpeed) {
cerr << _("upload-limit must be greater than or equal to 0.") << endl;
showUsage();
exit(EXIT_FAILURE);
}
- op->put(PREF_UPLOAD_LIMIT, Util::itos(uploadSpeed));
+ op->put(PREF_MAX_UPLOAD_LIMIT, Util::itos(uploadSpeed));
break;
}
case 21:
@@ -527,6 +538,16 @@ int main(int argc, char* argv[]) {
op->put(PREF_SEED_RATIO, optarg);
break;
}
+ case 24: {
+ int limit = getRealSize(optarg);
+ if(limit < 0) {
+ cerr << _("max-upload-limit must be greater than or equal to 0") << endl;
+ showUsage();
+ exit(EXIT_FAILURE);
+ }
+ op->put(PREF_MAX_UPLOAD_LIMIT, Util::itos(limit));
+ break;
+ }
case 100:
op->put(PREF_METALINK_VERSION, optarg);
break;
@@ -557,6 +578,16 @@ int main(int argc, char* argv[]) {
op->put(PREF_LOWEST_SPEED_LIMIT, Util::itos(limit));
break;
}
+ case 201: {
+ int limit = getRealSize(optarg);
+ if(limit < 0) {
+ cerr << _("max-download-limit must be greater than or equal to 0") << endl;
+ showUsage();
+ exit(EXIT_FAILURE);
+ }
+ op->put(PREF_MAX_DOWNLOAD_LIMIT, Util::itos(limit));
+ break;
+ }
}
break;
}
@@ -654,7 +685,6 @@ int main(int argc, char* argv[]) {
exit(EXIT_FAILURE);
}
}
-
Strings args(argv+optind, argv+argc);
#ifdef HAVE_LIBSSL
diff --git a/src/prefs.h b/src/prefs.h
index de1cd723..ed2776a2 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -62,7 +62,7 @@
// value: 1*digit
#define PREF_SEGMENT_SIZE "segment_size"
// value: 1*digit
-#define PREF_MAX_SPEED_LIMIT "max_speed_limit"
+#define PREF_MAX_DOWNLOAD_LIMIT "max_download_limit"
// value: 1*digit
#define PREF_STARTUP_IDLE_TIME "startup_idle_time"
@@ -121,7 +121,7 @@
// values: true | false
#define PREF_DIRECT_FILE_MAPPING "direct_file_mapping"
// values: 1*digit
-#define PREF_UPLOAD_LIMIT "upload_limit"
+#define PREF_MAX_UPLOAD_LIMIT "max_upload_limit"
// values: a string that your file system recognizes as a file name.
#define PREF_TORRENT_FILE "torrent_file"
// values: 1*digit