From f3973e5a12e6ad531cc8fd55a764c86d5d389213 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 7 Mar 2010 03:10:19 +0000 Subject: [PATCH] 2010-03-07 Tatsuhiro Tsujikawa Create CreateRequestCommand to the number of -s/-C when URIs are added by XML-RPC. * src/RequestGroup.cc * src/RequestGroup.h * src/XmlRpcMethodImpl.cc --- ChangeLog | 8 ++++++++ src/RequestGroup.cc | 23 +++++++++++++++++++++++ src/RequestGroup.h | 2 ++ src/XmlRpcMethodImpl.cc | 5 +++++ 4 files changed, 38 insertions(+) diff --git a/ChangeLog b/ChangeLog index 12deaa18..6564c96c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-03-07 Tatsuhiro Tsujikawa + + Create CreateRequestCommand to the number of -s/-C when URIs are + added by XML-RPC. + * src/RequestGroup.cc + * src/RequestGroup.h + * src/XmlRpcMethodImpl.cc + 2010-03-07 Tatsuhiro Tsujikawa Added 'status' key to the response of getUri XML-RPC method. diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 42074b9e..13df5454 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -684,6 +684,29 @@ void RequestGroup::createNextCommandWithAdj(std::vector& commands, } } +void RequestGroup::createNextCommand(std::vector& commands, + DownloadEngine* e) +{ + int numCommand; + if(getTotalLength() == 0) { + if(_numStreamConnection > 0) { + numCommand = 0; + } else { + numCommand = 1; + } + } else { + if(_numStreamConnection >= _numConcurrentCommand) { + numCommand = 0; + } else { + numCommand = std::min(_downloadContext->getNumPieces(), + _numConcurrentCommand-_numStreamConnection); + } + } + if(numCommand > 0) { + createNextCommand(commands, e, numCommand); + } +} + void RequestGroup::createNextCommand(std::vector& commands, DownloadEngine* e, unsigned int numCommand) diff --git a/src/RequestGroup.h b/src/RequestGroup.h index bef34b84..dcd3093c 100644 --- a/src/RequestGroup.h +++ b/src/RequestGroup.h @@ -208,6 +208,8 @@ public: void createNextCommand(std::vector& commands, DownloadEngine* e, unsigned int numCommand); + void createNextCommand(std::vector& commands, DownloadEngine* e); + bool downloadFinished() const; bool allDownloadFinished() const; diff --git a/src/XmlRpcMethodImpl.cc b/src/XmlRpcMethodImpl.cc index 285ce605..32344a6a 100644 --- a/src/XmlRpcMethodImpl.cc +++ b/src/XmlRpcMethodImpl.cc @@ -917,6 +917,11 @@ BDE ChangeUriXmlRpcMethod::process } } } + if(addcount) { + std::vector commands; + group->createNextCommand(commands, e); + e->addCommand(commands); + } BDE res = BDE::list(); res << delcount; res << addcount;