From 8f51793b19c751bde0e41448aaeb9eb54d2fdbb1 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 28 Jan 2016 23:43:29 +0900 Subject: Add --max-mmap-limit option Set the maximum file size to enable mmap (see --enable-mmap option). The file size is determined by the sum of all files contained in one download. For example, if a download contains 5 files, then file size is the total size of those files. If file size is strictly greater than the size specified in this option, mmap will be disabled. --- src/StreamFileAllocationEntry.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/StreamFileAllocationEntry.cc') diff --git a/src/StreamFileAllocationEntry.cc b/src/StreamFileAllocationEntry.cc index c6d1de2a..e02bbc48 100644 --- a/src/StreamFileAllocationEntry.cc +++ b/src/StreamFileAllocationEntry.cc @@ -66,7 +66,9 @@ void StreamFileAllocationEntry::prepareForNextAction( // RequestGroup::createInitialCommand() getRequestGroup()->getDownloadContext()->resetDownloadStartTime(); if (option->getAsBool(PREF_ENABLE_MMAP) && - option->get(PREF_FILE_ALLOCATION) != V_NONE) { + option->get(PREF_FILE_ALLOCATION) != V_NONE && + getRequestGroup()->getPieceStorage()->getDiskAdaptor()->size() <= + option->getAsLLInt(PREF_MAX_MMAP_LIMIT)) { getRequestGroup()->getPieceStorage()->getDiskAdaptor()->enableMmap(); } if (getNextCommand()) { -- cgit