diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-01-16 21:04:31 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-01-16 21:04:31 +0900 |
| commit | 97d0b71dd49fff4932085a206d2e3e8fe658788f (patch) | |
| tree | d7eb98230d46b1d4ccef947fcea5c743d850ba00 /src | |
| parent | 63fe7874daa45ad32475b2e9f04087ecb7621347 (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/FtpConnection.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index debde951..220bccf1 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -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 |
