소스 검색

Fix bug that causes bogus EOF connection failure in BitTorrent downloads

Tatsuhiro Tsujikawa 9 년 전
부모
커밋
ae11b7a85d
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      src/PeerConnection.cc

+ 2 - 2
src/PeerConnection.cc

@@ -124,7 +124,7 @@ bool PeerConnection::receiveMessage(unsigned char* data, size_t& dataLength)
         }
         break;
       case (BT_MSG_READ_PAYLOAD):
-        // We chosen the bufferCapacity_ so that whole message,
+        // We chose the bufferCapacity_ so that whole message,
         // including 4 bytes length and payload, in it. So here we
         // just make sure that it happens.
         if (resbufLength_ - msgOffset_ >= 4 + currentPayloadLength_) {
@@ -150,7 +150,7 @@ bool PeerConnection::receiveMessage(unsigned char* data, size_t& dataLength)
     else {
       assert(resbufOffset_ == resbufLength_);
       if (resbufLength_ != 0) {
-        if (msgOffset_ == 0 && resbufLength_ == currentPayloadLength_ + 4) {
+        if (resbufLength_ - msgOffset_ == currentPayloadLength_ + 4) {
           // All bytes in buffer have been processed, so clear it
           // away.
           resbufLength_ = 0;