2008-05-17 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Don't add closed socket to 
DownloadEngine::addSocketForReadCheck()
	* src/AbstractCommand.cc
	* src/AbstractCommand.h
	* src/ActivePeerConnectionCommand.cc
	* src/FtpInitiateConnectionCommand.cc
	* src/HttpInitiateConnectionCommand.cc
	* src/InitiateConnectionCommandFactory.cc
	* src/PeerAbstractCommand.cc
	* src/PeerAbstractCommand.h
	* src/PeerInitiateConnectionCommand.cc
	* src/TrackerWatcherCommand.cc
pull/1/head
Tatsuhiro Tsujikawa 2008-05-17 09:15:14 +00:00
parent b5f1ca6f66
commit 7c6ed037e3
11 changed files with 31 additions and 39 deletions

View File

@ -1,3 +1,17 @@
2008-05-17 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Don't add closed socket to DownloadEngine::addSocketForReadCheck()
* src/AbstractCommand.cc
* src/AbstractCommand.h
* src/ActivePeerConnectionCommand.cc
* src/FtpInitiateConnectionCommand.cc
* src/HttpInitiateConnectionCommand.cc
* src/InitiateConnectionCommandFactory.cc
* src/PeerAbstractCommand.cc
* src/PeerAbstractCommand.h
* src/PeerInitiateConnectionCommand.cc
* src/TrackerWatcherCommand.cc
2008-05-17 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Sort RequestSlot in ascending order and manipulate them using

View File

@ -58,8 +58,6 @@
namespace aria2 {
// TODO $$$$$$$$$$$ fix two nearly identical constructor. $$$$$$$$$$$$$$
// Modify two constructor at the same time!
AbstractCommand::AbstractCommand(int32_t cuid,
const SharedHandle<Request>& req,
RequestGroup* requestGroup,
@ -69,22 +67,10 @@ AbstractCommand::AbstractCommand(int32_t cuid,
req(req), e(e), socket(s),
checkSocketIsReadable(false), checkSocketIsWritable(false),
nameResolverCheck(false)
{
setReadCheckSocket(socket);
timeout = this->e->option->getAsInt(PREF_TIMEOUT);
_requestGroup->increaseStreamConnection();
}
AbstractCommand::AbstractCommand(int32_t cuid,
const SharedHandle<Request>& req,
RequestGroup* requestGroup,
DownloadEngine* e):
Command(cuid), RequestGroupAware(requestGroup),
req(req), e(e), socket(new SocketCore()),
checkSocketIsReadable(false), checkSocketIsWritable(false),
nameResolverCheck(false)
{
setReadCheckSocket(socket);
{
if(!socket.isNull() && socket->isOpen()) {
setReadCheckSocket(socket);
}
timeout = this->e->option->getAsInt(PREF_TIMEOUT);
_requestGroup->increaseStreamConnection();
}

View File

@ -106,10 +106,7 @@ private:
public:
AbstractCommand(int32_t cuid, const SharedHandle<Request>& req,
RequestGroup* requestGroup, DownloadEngine* e,
const SharedHandle<SocketCore>& s);
AbstractCommand(int32_t cuid, const SharedHandle<Request>& req,
RequestGroup* requestGroup, DownloadEngine* e);
const SharedHandle<SocketCore>& s = SharedHandle<SocketCore>());
virtual ~AbstractCommand();
bool execute();

View File

@ -46,6 +46,7 @@
#include "prefs.h"
#include "Option.h"
#include "BtConstants.h"
#include "SocketCore.h"
namespace aria2 {

View File

@ -67,6 +67,7 @@ Command* FtpInitiateConnectionCommand::createNextCommand
logger->info(MSG_CONNECTING_TO_SERVER, cuid,
e->option->get(PREF_HTTP_PROXY_HOST).c_str(),
e->option->getAsInt(PREF_HTTP_PROXY_PORT));
socket.reset(new SocketCore());
socket->establishConnection(resolvedAddresses.front(),
e->option->getAsInt(PREF_HTTP_PROXY_PORT));
@ -86,6 +87,7 @@ Command* FtpInitiateConnectionCommand::createNextCommand
logger->info(MSG_CONNECTING_TO_SERVER, cuid, req->getHost().c_str(),
req->getPort());
socket.reset(new SocketCore());
socket->establishConnection(resolvedAddresses.front(), req->getPort());
command = new FtpNegotiationCommand(cuid, req, _requestGroup, e, socket);
} else {

View File

@ -66,6 +66,7 @@ Command* HttpInitiateConnectionCommand::createNextCommand
logger->info(MSG_CONNECTING_TO_SERVER, cuid,
e->option->get(PREF_HTTP_PROXY_HOST).c_str(),
e->option->getAsInt(PREF_HTTP_PROXY_PORT));
socket.reset(new SocketCore());
socket->establishConnection(resolvedAddresses.front(),
e->option->getAsInt(PREF_HTTP_PROXY_PORT));
if(useProxyTunnel()) {
@ -84,6 +85,7 @@ Command* HttpInitiateConnectionCommand::createNextCommand
if(pooledSocket.isNull()) {
logger->info(MSG_CONNECTING_TO_SERVER, cuid, req->getHost().c_str(),
req->getPort());
socket.reset(new SocketCore());
socket->establishConnection(resolvedAddresses.front(), req->getPort());
} else {
socket = pooledSocket;

View File

@ -42,6 +42,7 @@
#include "StringFormat.h"
#include "Option.h"
#include "prefs.h"
#include "SocketCore.h"
namespace aria2 {

View File

@ -52,18 +52,9 @@ PeerAbstractCommand::PeerAbstractCommand(int32_t cuid,
checkSocketIsReadable(false), checkSocketIsWritable(false),
uploadLimitCheck(false), uploadLimit(0), noCheck(false)
{
setReadCheckSocket(socket);
timeout = e->option->getAsInt(PREF_BT_TIMEOUT);
}
PeerAbstractCommand::PeerAbstractCommand(int32_t cuid,
const PeerHandle& peer,
DownloadEngine* e)
:Command(cuid), e(e), socket(new SocketCore()), peer(peer),
checkSocketIsReadable(false), checkSocketIsWritable(false),
uploadLimitCheck(false), uploadLimit(0), noCheck(false)
{
setReadCheckSocket(socket);
if(!socket.isNull() && socket->isOpen()) {
setReadCheckSocket(socket);
}
timeout = e->option->getAsInt(PREF_BT_TIMEOUT);
}

View File

@ -80,11 +80,7 @@ public:
PeerAbstractCommand(int32_t cuid,
const SharedHandle<Peer>& peer,
DownloadEngine* e,
const SharedHandle<SocketCore>& s);
PeerAbstractCommand(int32_t cuid,
const SharedHandle<Peer>& peer,
DownloadEngine* e);
const SharedHandle<SocketCore>& s = SharedHandle<SocketCore>());
virtual ~PeerAbstractCommand();

View File

@ -75,6 +75,7 @@ PeerInitiateConnectionCommand::~PeerInitiateConnectionCommand()
bool PeerInitiateConnectionCommand::executeInternal() {
logger->info(MSG_CONNECTING_TO_SERVER, cuid, peer->ipaddr.c_str(),
peer->port);
socket.reset(new SocketCore());
socket->establishConnection(peer->ipaddr, peer->port);
Command* command;
if(_mseHandshakeEnabled) {

View File

@ -54,6 +54,7 @@
#include "DlAbortEx.h"
#include "Logger.h"
#include "A2STR.h"
#include "SocketCore.h"
#include <sstream>
namespace aria2 {