mirror of https://github.com/aria2/aria2
2008-02-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Make listening socket non-block mode. * src/FtpConnection.cc * src/FtpNegotiationCommand.{h, cc} * src/PeerListenCommand.cc Fixed the bug that cause slow ftp negotiation. * src/FtpNegotiationCommand.{h, cc}pull/1/head
parent
766e092af3
commit
80bc9a8a21
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2008-02-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Make listening socket non-block mode.
|
||||||
|
* src/FtpConnection.cc
|
||||||
|
* src/FtpNegotiationCommand.{h, cc}
|
||||||
|
* src/PeerListenCommand.cc
|
||||||
|
|
||||||
|
Fixed the bug that cause slow ftp negotiation.
|
||||||
|
* src/FtpNegotiationCommand.{h, cc}
|
||||||
|
|
||||||
2008-02-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-02-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Added basic tag to --enable-dht, --dht-listen-port option.
|
Added basic tag to --enable-dht, --dht-listen-port option.
|
||||||
|
|
|
@ -109,6 +109,7 @@ SocketHandle FtpConnection::sendPort() const
|
||||||
SocketHandle serverSocket;
|
SocketHandle serverSocket;
|
||||||
serverSocket->bind(0);
|
serverSocket->bind(0);
|
||||||
serverSocket->beginListen();
|
serverSocket->beginListen();
|
||||||
|
serverSocket->setNonBlockingMode();
|
||||||
|
|
||||||
std::pair<std::string, int32_t> addrinfo;
|
std::pair<std::string, int32_t> addrinfo;
|
||||||
socket->getAddrInfo(addrinfo);
|
socket->getAddrInfo(addrinfo);
|
||||||
|
|
|
@ -246,7 +246,7 @@ bool FtpNegotiationCommand::recvSize() {
|
||||||
|
|
||||||
sequence = SEQ_FILE_PREPARATION;
|
sequence = SEQ_FILE_PREPARATION;
|
||||||
disableReadCheckSocket();
|
disableReadCheckSocket();
|
||||||
setWriteCheckSocket(dataSocket);
|
//setWriteCheckSocket(dataSocket);
|
||||||
|
|
||||||
//e->noWait = true;
|
//e->noWait = true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -261,7 +261,13 @@ bool FtpNegotiationCommand::recvSize() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FtpNegotiationCommand::afterFileAllocation()
|
||||||
|
{
|
||||||
|
setReadCheckSocket(socket);
|
||||||
|
}
|
||||||
|
|
||||||
bool FtpNegotiationCommand::sendPort() {
|
bool FtpNegotiationCommand::sendPort() {
|
||||||
|
afterFileAllocation();
|
||||||
serverSocket = ftp->sendPort();
|
serverSocket = ftp->sendPort();
|
||||||
sequence = SEQ_RECV_PORT;
|
sequence = SEQ_RECV_PORT;
|
||||||
return false;
|
return false;
|
||||||
|
@ -280,6 +286,7 @@ bool FtpNegotiationCommand::recvPort() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FtpNegotiationCommand::sendPasv() {
|
bool FtpNegotiationCommand::sendPasv() {
|
||||||
|
afterFileAllocation();
|
||||||
ftp->sendPasv();
|
ftp->sendPasv();
|
||||||
sequence = SEQ_RECV_PASV;
|
sequence = SEQ_RECV_PASV;
|
||||||
return false;
|
return false;
|
||||||
|
@ -347,12 +354,24 @@ bool FtpNegotiationCommand::recvRetr() {
|
||||||
if(status != 150 && status != 125) {
|
if(status != 150 && status != 125) {
|
||||||
throw new DlAbortEx(EX_BAD_STATUS, status);
|
throw new DlAbortEx(EX_BAD_STATUS, status);
|
||||||
}
|
}
|
||||||
if(e->option->get(PREF_FTP_PASV) != V_TRUE) {
|
if(e->option->getAsBool(PREF_FTP_PASV)) {
|
||||||
assert(serverSocket->getSockfd() != -1);
|
|
||||||
dataSocket = serverSocket->acceptConnection();
|
|
||||||
}
|
|
||||||
sequence = SEQ_NEGOTIATION_COMPLETED;
|
sequence = SEQ_NEGOTIATION_COMPLETED;
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
disableReadCheckSocket();
|
||||||
|
setReadCheckSocket(serverSocket);
|
||||||
|
sequence = SEQ_WAIT_CONNECTION;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FtpNegotiationCommand::waitConnection()
|
||||||
|
{
|
||||||
|
disableReadCheckSocket();
|
||||||
|
setReadCheckSocket(socket);
|
||||||
|
dataSocket = serverSocket->acceptConnection();
|
||||||
|
dataSocket->setBlockingMode();
|
||||||
|
sequence = SEQ_NEGOTIATION_COMPLETED;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,6 +418,8 @@ bool FtpNegotiationCommand::processSequence(const SegmentHandle& segment) {
|
||||||
return sendRetr();
|
return sendRetr();
|
||||||
case SEQ_RECV_RETR:
|
case SEQ_RECV_RETR:
|
||||||
return recvRetr();
|
return recvRetr();
|
||||||
|
case SEQ_WAIT_CONNECTION:
|
||||||
|
return waitConnection();
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ private:
|
||||||
SEQ_RECV_REST,
|
SEQ_RECV_REST,
|
||||||
SEQ_SEND_RETR,
|
SEQ_SEND_RETR,
|
||||||
SEQ_RECV_RETR,
|
SEQ_RECV_RETR,
|
||||||
|
SEQ_WAIT_CONNECTION,
|
||||||
SEQ_NEGOTIATION_COMPLETED,
|
SEQ_NEGOTIATION_COMPLETED,
|
||||||
SEQ_RETRY,
|
SEQ_RETRY,
|
||||||
SEQ_HEAD_OK,
|
SEQ_HEAD_OK,
|
||||||
|
@ -91,8 +92,11 @@ private:
|
||||||
bool recvRest();
|
bool recvRest();
|
||||||
bool sendRetr();
|
bool sendRetr();
|
||||||
bool recvRetr();
|
bool recvRetr();
|
||||||
|
bool waitConnection();
|
||||||
bool processSequence(const SharedHandle<Segment>& segment);
|
bool processSequence(const SharedHandle<Segment>& segment);
|
||||||
|
|
||||||
|
void afterFileAllocation();
|
||||||
|
|
||||||
SharedHandle<SocketCore> dataSocket;
|
SharedHandle<SocketCore> dataSocket;
|
||||||
SharedHandle<SocketCore> serverSocket;
|
SharedHandle<SocketCore> serverSocket;
|
||||||
int32_t sequence;
|
int32_t sequence;
|
||||||
|
|
|
@ -70,6 +70,7 @@ int32_t PeerListenCommand::bindPort(IntSequence& seq)
|
||||||
try {
|
try {
|
||||||
socket->bind(port);
|
socket->bind(port);
|
||||||
socket->beginListen();
|
socket->beginListen();
|
||||||
|
socket->setNonBlockingMode();
|
||||||
logger->info(MSG_LISTENING_PORT,
|
logger->info(MSG_LISTENING_PORT,
|
||||||
cuid, port);
|
cuid, port);
|
||||||
return port;
|
return port;
|
||||||
|
|
Loading…
Reference in New Issue