소스 검색

2009-06-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Call setStatus(STATUS_ONESHOT_REALTIME) from constructor.  Call
	setNoWiat(true) if newly created command calls
	setStatus(STATUS_ONESHOT_REALTIME) from its constructor.
	* src/HttpListenCommand.cc
	* src/HttpServerBodyCommand.cc
	* src/HttpServerCommand.cc
	* src/HttpServerResponseCommand.cc
	* src/InitiateConnectionCommand.cc
	* src/RequestGroup.cc
	* src/StreamFileAllocationEntry.cc
Tatsuhiro Tsujikawa 16 년 전
부모
커밋
572f10af72

+ 13 - 0
ChangeLog

@@ -1,3 +1,16 @@
+2009-06-20  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Call setStatus(STATUS_ONESHOT_REALTIME) from constructor.  Call
+	setNoWiat(true) if newly created command calls
+	setStatus(STATUS_ONESHOT_REALTIME) from its constructor.
+	* src/HttpListenCommand.cc
+	* src/HttpServerBodyCommand.cc
+	* src/HttpServerCommand.cc
+	* src/HttpServerResponseCommand.cc
+	* src/InitiateConnectionCommand.cc
+	* src/RequestGroup.cc
+	* src/StreamFileAllocationEntry.cc
+
 2009-06-17  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Removed include vector

+ 0 - 1
src/HttpListenCommand.cc

@@ -72,7 +72,6 @@ bool HttpListenCommand::execute()
 
       HttpServerCommand* c =
 	new HttpServerCommand(_e->newCUID(), _e, socket);
-      c->setStatus(Command::STATUS_ONESHOT_REALTIME);
       _e->setNoWait(true);
       _e->commands.push_back(c);
     }

+ 1 - 1
src/HttpServerBodyCommand.cc

@@ -62,6 +62,7 @@ HttpServerBodyCommand::HttpServerBodyCommand
   _socket(socket),
   _httpServer(httpServer)
 {
+  setStatus(Command::STATUS_ONESHOT_REALTIME);
   _e->addSocketForReadCheck(_socket, this);
 }
 
@@ -91,7 +92,6 @@ bool HttpServerBodyCommand::execute()
 	  _httpServer->feedResponse(res.toXml(), "text/xml");
 	  Command* command =
 	    new HttpServerResponseCommand(cuid, _httpServer, _e, _socket);
-	  command->setStatus(Command::STATUS_ONESHOT_REALTIME);
 	  _e->commands.push_back(command);
 	  _e->setNoWait(true);
 	  return true;

+ 1 - 2
src/HttpServerCommand.cc

@@ -56,6 +56,7 @@ HttpServerCommand::HttpServerCommand(int32_t cuid, DownloadEngine* e,
   _socket(socket),
   _httpServer(new HttpServer(socket, e))
 {
+  setStatus(Command::STATUS_ONESHOT_REALTIME);
   _e->addSocketForReadCheck(_socket, this);
   _httpServer->setUsernamePassword(_e->option->get(PREF_XML_RPC_USER),
 				   _e->option->get(PREF_XML_RPC_PASSWD));
@@ -96,7 +97,6 @@ bool HttpServerCommand::execute()
 				  "","text/html");
 	Command* command =
 	  new HttpServerResponseCommand(cuid, _httpServer, _e, _socket);
-	command->setStatus(Command::STATUS_ONESHOT_REALTIME);
 	_e->commands.push_back(command);
 	_e->setNoWait(true);
 	return true;
@@ -115,7 +115,6 @@ bool HttpServerCommand::execute()
       } else {
 	Command* command = new HttpServerBodyCommand(cuid, _httpServer, _e,
 						     _socket);
-	command->setStatus(Command::STATUS_ONESHOT_REALTIME);
 	_e->commands.push_back(command);
 	_e->setNoWait(true);
 	return true;

+ 1 - 1
src/HttpServerResponseCommand.cc

@@ -53,7 +53,7 @@ HttpServerResponseCommand::HttpServerResponseCommand
   _socket(socket),
  _httpServer(httpServer)
 {
- 
+  setStatus(Command::STATUS_ONESHOT_REALTIME); 
   _e->addSocketForWriteCheck(_socket, this);
 }
 

+ 1 - 0
src/InitiateConnectionCommand.cc

@@ -53,6 +53,7 @@ InitiateConnectionCommand::InitiateConnectionCommand
   AbstractCommand(cuid, req, requestGroup, e)
 {
   setTimeout(getOption()->getAsInt(PREF_DNS_TIMEOUT));
+  // give a chance to be executed in the next loop in DownloadEngine
   setStatus(Command::STATUS_ONESHOT_REALTIME);
   disableReadCheckSocket();
   disableWriteCheckSocket();

+ 3 - 2
src/RequestGroup.cc

@@ -659,8 +659,6 @@ void RequestGroup::createNextCommand(std::deque<Command*>& commands,
 	  (e->newCUID(), req, this, e);
 	ServerHostHandle sv(new ServerHost(command->getCuid(), req->getHost()));
 	registerServerHost(sv);
-	// give a chance to be executed in the next loop in DownloadEngine
-	command->setStatus(Command::STATUS_ONESHOT_REALTIME);
 	commands.push_back(command);
       } else {
 	pendingURIs.push_back(uri);
@@ -670,6 +668,9 @@ void RequestGroup::createNextCommand(std::deque<Command*>& commands,
     }
   }
   _uris.insert(_uris.begin(), pendingURIs.begin(), pendingURIs.end());
+  if(!commands.empty()) {
+    e->setNoWait(true);
+  }
 }
 
 std::string RequestGroup::getFilePath() const

+ 2 - 2
src/StreamFileAllocationEntry.cc

@@ -63,6 +63,7 @@ void StreamFileAllocationEntry::prepareForNextAction(std::deque<Command*>& comma
   if(_nextCommand) {
     // give _nextCommand a chance to execute in the next execution loop.
     _nextCommand->setStatus(Command::STATUS_ONESHOT_REALTIME);
+    e->setNoWait(true);
     commands.push_back(popNextCommand());
     // try remaining uris
     _requestGroup->createNextCommandWithAdj(commands, e, -1);
@@ -73,9 +74,8 @@ void StreamFileAllocationEntry::prepareForNextAction(std::deque<Command*>& comma
       Command* command =
 	InitiateConnectionCommandFactory::createInitiateConnectionCommand
 	(e->newCUID(), _currentRequest, _requestGroup, e);
-
+      e->setNoWait(true);
       commands.push_back(command);
-
       _requestGroup->createNextCommandWithAdj(commands, e, -1);
     }
   }