mirror of
https://github.com/aria2/aria2.git
synced 2025-02-26 08:22:11 +00:00
Don't use SocketCore::isReadable() repeatedly.
We can know whether data is available by inspecting 2nd argument of SocketCore::readData() because we use non-blocking I/O.
This commit is contained in:
parent
63fe7874da
commit
97d0b71dd4
@ -363,14 +363,15 @@ bool FtpConnection::bulkReceiveResponse
|
|||||||
(std::pair<unsigned int, std::string>& response)
|
(std::pair<unsigned int, std::string>& response)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
while(socket_->isReadable(0)) {
|
while(1) {
|
||||||
size_t size = sizeof(buf);
|
size_t size = sizeof(buf);
|
||||||
socket_->readData(buf, size);
|
socket_->readData(buf, size);
|
||||||
if(size == 0) {
|
if(size == 0) {
|
||||||
if(socket_->wantRead() || socket_->wantWrite()) {
|
if(socket_->wantRead() || socket_->wantWrite()) {
|
||||||
return false;
|
break;
|
||||||
|
} else {
|
||||||
|
throw DL_RETRY_EX(EX_GOT_EOF);
|
||||||
}
|
}
|
||||||
throw DL_RETRY_EX(EX_GOT_EOF);
|
|
||||||
}
|
}
|
||||||
if(strbuf_.size()+size > MAX_RECV_BUFFER) {
|
if(strbuf_.size()+size > MAX_RECV_BUFFER) {
|
||||||
throw DL_RETRY_EX
|
throw DL_RETRY_EX
|
||||||
|
@ -63,7 +63,6 @@ public:
|
|||||||
clientSocket_->establishConnection("localhost", listenPort_);
|
clientSocket_->establishConnection("localhost", listenPort_);
|
||||||
|
|
||||||
while(!clientSocket_->isWritable(0));
|
while(!clientSocket_->isWritable(0));
|
||||||
clientSocket_->setBlockingMode();
|
|
||||||
|
|
||||||
serverSocket_.reset(listenSocket->acceptConnection());
|
serverSocket_.reset(listenSocket->acceptConnection());
|
||||||
ftp_.reset(new FtpConnection(1, clientSocket_, req_,
|
ftp_.reset(new FtpConnection(1, clientSocket_, req_,
|
||||||
|
Loading…
Reference in New Issue
Block a user