diff options
| -rw-r--r-- | src/AbstractCommand.cc | 5 | ||||
| -rw-r--r-- | src/AbstractCommand.h | 4 | ||||
| -rw-r--r-- | src/CreateRequestCommand.cc | 4 |
3 files changed, 13 insertions, 0 deletions
diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index 7276a755..6b478bfc 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -896,6 +896,11 @@ void AbstractCommand::setRequest(const SharedHandle<Request>& request) req_ = request; } +void AbstractCommand::resetRequest() +{ + req_.reset(); +} + void AbstractCommand::setFileEntry(const SharedHandle<FileEntry>& fileEntry) { fileEntry_ = fileEntry; diff --git a/src/AbstractCommand.h b/src/AbstractCommand.h index 8ba57fad..939736cc 100644 --- a/src/AbstractCommand.h +++ b/src/AbstractCommand.h @@ -110,6 +110,10 @@ protected: void setRequest(const SharedHandle<Request>& request); + // Resets request_. This method is more efficient than + // setRequest(SharedHandle<Request>()); + void resetRequest(); + const SharedHandle<FileEntry>& getFileEntry() const { return fileEntry_; diff --git a/src/CreateRequestCommand.cc b/src/CreateRequestCommand.cc index 21edc397..d46936dd 100644 --- a/src/CreateRequestCommand.cc +++ b/src/CreateRequestCommand.cc @@ -101,6 +101,10 @@ bool CreateRequestCommand::executeInternal() } else if(getRequest()->getWakeTime() > global::wallclock()) { A2_LOG_DEBUG("This request object is still sleeping."); getFileEntry()->poolRequest(getRequest()); + // Reset request of this command. Without this, request is doubly + // counted (1 for pooled and another one in this command) and + // AbstractCommand::execute() will behave badly. + resetRequest(); getDownloadEngine()->addCommand(this); return false; } |
