mirror of https://github.com/aria2/aria2
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.pull/1/head
parent
63fe7874da
commit
97d0b71dd4
|
@ -363,14 +363,15 @@ bool FtpConnection::bulkReceiveResponse
|
|||
(std::pair<unsigned int, std::string>& response)
|
||||
{
|
||||
char buf[1024];
|
||||
while(socket_->isReadable(0)) {
|
||||
while(1) {
|
||||
size_t size = sizeof(buf);
|
||||
socket_->readData(buf, size);
|
||||
if(size == 0) {
|
||||
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) {
|
||||
throw DL_RETRY_EX
|
||||
|
|
|
@ -63,7 +63,6 @@ public:
|
|||
clientSocket_->establishConnection("localhost", listenPort_);
|
||||
|
||||
while(!clientSocket_->isWritable(0));
|
||||
clientSocket_->setBlockingMode();
|
||||
|
||||
serverSocket_.reset(listenSocket->acceptConnection());
|
||||
ftp_.reset(new FtpConnection(1, clientSocket_, req_,
|
||||
|
|
Loading…
Reference in New Issue