mirror of https://github.com/aria2/aria2
2008-06-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Returns cached data only when the previous receiveHandshake() is called with peek = true. * src/PeerConnection.cc (receiveHandshake) * src/PeerConnection.h (receiveHandshake)pull/1/head
parent
de9605815d
commit
811649149d
|
@ -1,3 +1,10 @@
|
||||||
|
2008-06-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Returns cached data only when the previous receiveHandshake() is called
|
||||||
|
with peek = true.
|
||||||
|
* src/PeerConnection.cc (receiveHandshake)
|
||||||
|
* src/PeerConnection.h (receiveHandshake)
|
||||||
|
|
||||||
2008-06-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-06-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Changed default value of -s option from 1 to 5.
|
Changed default value of -s option from 1 to 5.
|
||||||
|
|
|
@ -59,7 +59,8 @@ PeerConnection::PeerConnection(int32_t cuid,
|
||||||
resbufLength(0),
|
resbufLength(0),
|
||||||
currentPayloadLength(0),
|
currentPayloadLength(0),
|
||||||
lenbufLength(0),
|
lenbufLength(0),
|
||||||
_encryptionEnabled(false)
|
_encryptionEnabled(false),
|
||||||
|
_prevPeek(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
PeerConnection::~PeerConnection() {}
|
PeerConnection::~PeerConnection() {}
|
||||||
|
@ -130,15 +131,19 @@ bool PeerConnection::receiveMessage(unsigned char* data, size_t& dataLength) {
|
||||||
|
|
||||||
bool PeerConnection::receiveHandshake(unsigned char* data, size_t& dataLength,
|
bool PeerConnection::receiveHandshake(unsigned char* data, size_t& dataLength,
|
||||||
bool peek) {
|
bool peek) {
|
||||||
|
assert(BtHandshakeMessage::MESSAGE_LENGTH >= resbufLength);
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
if(!peek && resbufLength) {
|
if(_prevPeek && !peek && resbufLength) {
|
||||||
// We have data in previous peek.
|
// We have data in previous peek.
|
||||||
// There is a chance that socket is readable because of EOF, for example,
|
// There is a chance that socket is readable because of EOF, for example,
|
||||||
// official bttrack shutdowns socket after sending first 48 bytes of
|
// official bttrack shutdowns socket after sending first 48 bytes of
|
||||||
// handshake in its NAT checking.
|
// handshake in its NAT checking.
|
||||||
// So if there are data in resbuf, return it without checking socket
|
// So if there are data in resbuf, return it without checking socket
|
||||||
// status.
|
// status.
|
||||||
|
_prevPeek = false;
|
||||||
|
retval = BtHandshakeMessage::MESSAGE_LENGTH <= resbufLength;
|
||||||
} else {
|
} else {
|
||||||
|
_prevPeek = peek;
|
||||||
size_t remaining = BtHandshakeMessage::MESSAGE_LENGTH-resbufLength;
|
size_t remaining = BtHandshakeMessage::MESSAGE_LENGTH-resbufLength;
|
||||||
if(remaining > 0 && !socket->isReadable(0)) {
|
if(remaining > 0 && !socket->isReadable(0)) {
|
||||||
dataLength = 0;
|
dataLength = 0;
|
||||||
|
|
|
@ -68,6 +68,8 @@ private:
|
||||||
SharedHandle<ARC4Encryptor> _encryptor;
|
SharedHandle<ARC4Encryptor> _encryptor;
|
||||||
SharedHandle<ARC4Decryptor> _decryptor;
|
SharedHandle<ARC4Decryptor> _decryptor;
|
||||||
|
|
||||||
|
bool _prevPeek;
|
||||||
|
|
||||||
void readData(unsigned char* data, size_t& length, bool encryption);
|
void readData(unsigned char* data, size_t& length, bool encryption);
|
||||||
|
|
||||||
void sendData(const unsigned char* data, size_t length, bool encryption);
|
void sendData(const unsigned char* data, size_t length, bool encryption);
|
||||||
|
|
Loading…
Reference in New Issue