mirror of https://github.com/aria2/aria2
2008-06-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added --bt-max-open-files option. * src/DefaultPieceStorage.cc * src/HelpItemFactory.cc * src/MultiDiskAdaptor.cc * src/MultiDiskAdaptor.h * src/OptionHandlerFactory.cc * src/option_processing.cc * src/prefs.cc * src/prefs.h * src/usage_text.hpull/1/head
parent
b4e5ba2779
commit
cf71523fe2
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2008-06-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Added --bt-max-open-files option.
|
||||||
|
* src/DefaultPieceStorage.cc
|
||||||
|
* src/HelpItemFactory.cc
|
||||||
|
* src/MultiDiskAdaptor.cc
|
||||||
|
* src/MultiDiskAdaptor.h
|
||||||
|
* src/OptionHandlerFactory.cc
|
||||||
|
* src/option_processing.cc
|
||||||
|
* src/prefs.cc
|
||||||
|
* src/prefs.h
|
||||||
|
* src/usage_text.h
|
||||||
|
|
||||||
2008-06-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-06-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Fixed the bug that aria2 aborts when a path to a directory is given
|
Fixed the bug that aria2 aborts when a path to a directory is given
|
||||||
|
|
|
@ -444,6 +444,7 @@ void DefaultPieceStorage::initStorage()
|
||||||
multiDiskAdaptor->setDirectIOAllowed(option->getAsBool(PREF_ENABLE_DIRECT_IO));
|
multiDiskAdaptor->setDirectIOAllowed(option->getAsBool(PREF_ENABLE_DIRECT_IO));
|
||||||
multiDiskAdaptor->setPieceLength(downloadContext->getPieceLength());
|
multiDiskAdaptor->setPieceLength(downloadContext->getPieceLength());
|
||||||
multiDiskAdaptor->setTopDir(downloadContext->getName());
|
multiDiskAdaptor->setTopDir(downloadContext->getName());
|
||||||
|
multiDiskAdaptor->setMaxOpenFiles(option->getAsInt(PREF_BT_MAX_OPEN_FILES));
|
||||||
this->diskAdaptor = multiDiskAdaptor;
|
this->diskAdaptor = multiDiskAdaptor;
|
||||||
} else {
|
} else {
|
||||||
logger->debug("Instantiating CopyDiskAdaptor");
|
logger->debug("Instantiating CopyDiskAdaptor");
|
||||||
|
|
|
@ -381,6 +381,13 @@ TagContainerHandle HelpItemFactory::createHelpItems(const Option* op)
|
||||||
item->addTag(TAG_BITTORRENT);
|
item->addTag(TAG_BITTORRENT);
|
||||||
tc->addItem(item);
|
tc->addItem(item);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
HelpItemHandle item(new HelpItem(PREF_BT_MAX_OPEN_FILES,
|
||||||
|
TEXT_BT_MAX_OPEN_FILES,
|
||||||
|
op->get(PREF_BT_MAX_OPEN_FILES)));
|
||||||
|
item->addTag(TAG_BITTORRENT);
|
||||||
|
tc->addItem(item);
|
||||||
|
}
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
#ifdef ENABLE_METALINK
|
#ifdef ENABLE_METALINK
|
||||||
{
|
{
|
||||||
|
|
|
@ -145,7 +145,7 @@ void DiskWriterEntry::disableDirectIO()
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiDiskAdaptor::MultiDiskAdaptor():
|
MultiDiskAdaptor::MultiDiskAdaptor():
|
||||||
pieceLength(0) {}
|
pieceLength(0), _maxOpenFiles(DEFAULT_MAX_OPEN_FILES) {}
|
||||||
|
|
||||||
MultiDiskAdaptor::~MultiDiskAdaptor() {}
|
MultiDiskAdaptor::~MultiDiskAdaptor() {}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ void MultiDiskAdaptor::openIfNot
|
||||||
|
|
||||||
size_t numOpened = _openedDiskWriterEntries.size();
|
size_t numOpened = _openedDiskWriterEntries.size();
|
||||||
(entry.get()->*open)(topDirPath);
|
(entry.get()->*open)(topDirPath);
|
||||||
if(numOpened >= OPEN_FILE_MAX) {
|
if(numOpened >= _maxOpenFiles) {
|
||||||
// Cache is full.
|
// Cache is full.
|
||||||
// Choose one DiskWriterEntry randomly and close it.
|
// Choose one DiskWriterEntry randomly and close it.
|
||||||
size_t index = SimpleRandomizer::getInstance()->getRandomNumber(numOpened);
|
size_t index = SimpleRandomizer::getInstance()->getRandomNumber(numOpened);
|
||||||
|
@ -386,4 +386,9 @@ void MultiDiskAdaptor::disableDirectIO()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MultiDiskAdaptor::setMaxOpenFiles(size_t maxOpenFiles)
|
||||||
|
{
|
||||||
|
_maxOpenFiles = maxOpenFiles;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -104,6 +104,8 @@ private:
|
||||||
|
|
||||||
std::deque<SharedHandle<DiskWriterEntry> > _openedDiskWriterEntries;
|
std::deque<SharedHandle<DiskWriterEntry> > _openedDiskWriterEntries;
|
||||||
|
|
||||||
|
size_t _maxOpenFiles;
|
||||||
|
|
||||||
bool _directIOAllowed;
|
bool _directIOAllowed;
|
||||||
|
|
||||||
void resetDiskWriterEntries();
|
void resetDiskWriterEntries();
|
||||||
|
@ -116,7 +118,7 @@ private:
|
||||||
void (DiskWriterEntry::*f)(const std::string&),
|
void (DiskWriterEntry::*f)(const std::string&),
|
||||||
const std::string& topDirPath);
|
const std::string& topDirPath);
|
||||||
|
|
||||||
static const size_t OPEN_FILE_MAX = 100;
|
static const size_t DEFAULT_MAX_OPEN_FILES = 100;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MultiDiskAdaptor();
|
MultiDiskAdaptor();
|
||||||
|
@ -178,6 +180,8 @@ public:
|
||||||
{
|
{
|
||||||
_directIOAllowed = b;
|
_directIOAllowed = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setMaxOpenFiles(size_t maxOpenFiles);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<MultiDiskAdaptor> MultiDiskAdaptorHandle;
|
typedef SharedHandle<MultiDiskAdaptor> MultiDiskAdaptorHandle;
|
||||||
|
|
|
@ -127,6 +127,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
||||||
handlers.push_back(SH(new ParameterOptionHandler(PREF_BT_MIN_CRYPTO_LEVEL, V_PLAIN, V_ARC4)));
|
handlers.push_back(SH(new ParameterOptionHandler(PREF_BT_MIN_CRYPTO_LEVEL, V_PLAIN, V_ARC4)));
|
||||||
handlers.push_back(SH(new BooleanOptionHandler(PREF_BT_REQUIRE_CRYPTO)));
|
handlers.push_back(SH(new BooleanOptionHandler(PREF_BT_REQUIRE_CRYPTO)));
|
||||||
handlers.push_back(SH(new NumberOptionHandler(PREF_BT_REQUEST_PEER_SPEED_LIMIT, 0)));
|
handlers.push_back(SH(new NumberOptionHandler(PREF_BT_REQUEST_PEER_SPEED_LIMIT, 0)));
|
||||||
|
handlers.push_back(SH(new NumberOptionHandler(PREF_BT_MAX_OPEN_FILES, 1)));
|
||||||
handlers.push_back(SH(new CumulativeOptionHandler(PREF_HEADER, "\n")));
|
handlers.push_back(SH(new CumulativeOptionHandler(PREF_HEADER, "\n")));
|
||||||
handlers.push_back(SH(new BooleanOptionHandler(PREF_QUIET)));
|
handlers.push_back(SH(new BooleanOptionHandler(PREF_QUIET)));
|
||||||
#ifdef ENABLE_ASYNC_DNS
|
#ifdef ENABLE_ASYNC_DNS
|
||||||
|
|
|
@ -144,6 +144,7 @@ Option* createDefaultOption()
|
||||||
op->put(PREF_BT_MIN_CRYPTO_LEVEL, V_PLAIN);
|
op->put(PREF_BT_MIN_CRYPTO_LEVEL, V_PLAIN);
|
||||||
op->put(PREF_BT_REQUIRE_CRYPTO, V_FALSE);
|
op->put(PREF_BT_REQUIRE_CRYPTO, V_FALSE);
|
||||||
op->put(PREF_BT_REQUEST_PEER_SPEED_LIMIT, "51200");
|
op->put(PREF_BT_REQUEST_PEER_SPEED_LIMIT, "51200");
|
||||||
|
op->put(PREF_BT_MAX_OPEN_FILES, "100");
|
||||||
op->put(PREF_QUIET, V_FALSE);
|
op->put(PREF_QUIET, V_FALSE);
|
||||||
op->put(PREF_STOP, "0");
|
op->put(PREF_STOP, "0");
|
||||||
#ifdef ENABLE_ASYNC_DNS
|
#ifdef ENABLE_ASYNC_DNS
|
||||||
|
@ -254,6 +255,7 @@ Option* option_processing(int argc, char* const argv[])
|
||||||
{ PREF_BT_MIN_CRYPTO_LEVEL.c_str(), required_argument, &lopt, 30 },
|
{ PREF_BT_MIN_CRYPTO_LEVEL.c_str(), required_argument, &lopt, 30 },
|
||||||
{ PREF_BT_REQUIRE_CRYPTO.c_str(), required_argument, &lopt, 31 },
|
{ PREF_BT_REQUIRE_CRYPTO.c_str(), required_argument, &lopt, 31 },
|
||||||
{ PREF_BT_REQUEST_PEER_SPEED_LIMIT.c_str(), required_argument, &lopt, 32 },
|
{ PREF_BT_REQUEST_PEER_SPEED_LIMIT.c_str(), required_argument, &lopt, 32 },
|
||||||
|
{ PREF_BT_MAX_OPEN_FILES.c_str(), required_argument, &lopt, 33},
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
#ifdef ENABLE_METALINK
|
#ifdef ENABLE_METALINK
|
||||||
{ PREF_METALINK_FILE.c_str(), required_argument, NULL, 'M' },
|
{ PREF_METALINK_FILE.c_str(), required_argument, NULL, 'M' },
|
||||||
|
@ -367,6 +369,9 @@ Option* option_processing(int argc, char* const argv[])
|
||||||
case 32:
|
case 32:
|
||||||
cmdstream << PREF_BT_REQUEST_PEER_SPEED_LIMIT << "=" << optarg << "\n";
|
cmdstream << PREF_BT_REQUEST_PEER_SPEED_LIMIT << "=" << optarg << "\n";
|
||||||
break;
|
break;
|
||||||
|
case 33:
|
||||||
|
cmdstream << PREF_BT_MAX_OPEN_FILES << "=" << optarg << "\n";
|
||||||
|
break;
|
||||||
case 100:
|
case 100:
|
||||||
cmdstream << PREF_METALINK_VERSION << "=" << optarg << "\n";
|
cmdstream << PREF_METALINK_VERSION << "=" << optarg << "\n";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -249,6 +249,8 @@ const std::string V_ARC4("arc4");
|
||||||
const std::string PREF_BT_REQUIRE_CRYPTO("bt-require-crypto");
|
const std::string PREF_BT_REQUIRE_CRYPTO("bt-require-crypto");
|
||||||
// values: 1*digit
|
// values: 1*digit
|
||||||
const std::string PREF_BT_REQUEST_PEER_SPEED_LIMIT("bt-request-peer-speed-limit");
|
const std::string PREF_BT_REQUEST_PEER_SPEED_LIMIT("bt-request-peer-speed-limit");
|
||||||
|
// values: 1*digit
|
||||||
|
const std::string PREF_BT_MAX_OPEN_FILES("bt-max-open-files");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metalink related preferences
|
* Metalink related preferences
|
||||||
|
|
|
@ -253,6 +253,8 @@ extern const std::string V_ARC4;
|
||||||
extern const std::string PREF_BT_REQUIRE_CRYPTO;
|
extern const std::string PREF_BT_REQUIRE_CRYPTO;
|
||||||
// values: 1*digit
|
// values: 1*digit
|
||||||
extern const std::string PREF_BT_REQUEST_PEER_SPEED_LIMIT;
|
extern const std::string PREF_BT_REQUEST_PEER_SPEED_LIMIT;
|
||||||
|
// values: 1*digit
|
||||||
|
extern const std::string PREF_BT_MAX_OPEN_FILES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metalink related preferences
|
* Metalink related preferences
|
||||||
|
|
|
@ -279,6 +279,9 @@ _(" --bt-request-peer-speed-limit=SPEED In BitTorrent downloads, if the download
|
||||||
" speed is lower than SPEED, aria2 initiates and\n"\
|
" speed is lower than SPEED, aria2 initiates and\n"\
|
||||||
" accepts connections ignoring max peer cap.\n"\
|
" accepts connections ignoring max peer cap.\n"\
|
||||||
" You can append K or M(1K = 1024, 1M = 1024K).")
|
" You can append K or M(1K = 1024, 1M = 1024K).")
|
||||||
|
#define TEXT_BT_MAX_OPEN_FILES \
|
||||||
|
_(" --bt-max-open-files=NUM Specify maximum number of files to open in each\n"\
|
||||||
|
" BitTorrent download.")
|
||||||
#define TEXT_METALINK_FILE \
|
#define TEXT_METALINK_FILE \
|
||||||
_(" -M, --metalink-file=METALINK_FILE The file path to the .metalink file.")
|
_(" -M, --metalink-file=METALINK_FILE The file path to the .metalink file.")
|
||||||
#define TEXT_METALINK_SERVERS \
|
#define TEXT_METALINK_SERVERS \
|
||||||
|
|
Loading…
Reference in New Issue