forked from premiere/premiere-libtorrent
fixed bug when receiving keepalive message
This commit is contained in:
parent
4137f47386
commit
3c51ceb7c5
|
@ -2035,6 +2035,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(!m_rc4_encrypted);
|
TORRENT_ASSERT(!m_rc4_encrypted);
|
||||||
TORRENT_ASSERT(packet_size() == dh_key_len);
|
TORRENT_ASSERT(packet_size() == dh_key_len);
|
||||||
TORRENT_ASSERT(recv_buffer == receive_buffer());
|
TORRENT_ASSERT(recv_buffer == receive_buffer());
|
||||||
|
TORRENT_ASSERT(packet_size() == 5);
|
||||||
|
|
||||||
if (!packet_finished()) return;
|
if (!packet_finished()) return;
|
||||||
|
|
||||||
|
|
|
@ -2999,6 +2999,8 @@ namespace libtorrent
|
||||||
return m_disk_recv_buffer.release();
|
return m_disk_recv_buffer.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// size = the packet size to remove from the receive buffer
|
||||||
|
// packet_size = the next packet size to receive in the buffer
|
||||||
void peer_connection::cut_receive_buffer(int size, int packet_size)
|
void peer_connection::cut_receive_buffer(int size, int packet_size)
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
|
@ -97,6 +97,19 @@ void send_suggest_piece(stream_socket& s, int piece)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void send_keepalive(stream_socket& s)
|
||||||
|
{
|
||||||
|
std::cout << "send keepalive" << std::endl;
|
||||||
|
char msg[] = "\0\0\0\0";
|
||||||
|
error_code ec;
|
||||||
|
libtorrent::asio::write(s, libtorrent::asio::buffer(msg, 4), libtorrent::asio::transfer_all(), ec);
|
||||||
|
if (ec)
|
||||||
|
{
|
||||||
|
std::cout << ec.message() << std::endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void send_unchoke(stream_socket& s)
|
void send_unchoke(stream_socket& s)
|
||||||
{
|
{
|
||||||
std::cout << "send unchoke" << std::endl;
|
std::cout << "send unchoke" << std::endl;
|
||||||
|
@ -249,6 +262,8 @@ void test_respect_suggest()
|
||||||
|
|
||||||
send_unchoke(s);
|
send_unchoke(s);
|
||||||
|
|
||||||
|
send_keepalive(s);
|
||||||
|
|
||||||
int fail_counter = 100;
|
int fail_counter = 100;
|
||||||
while (!suggested.empty() && fail_counter > 0)
|
while (!suggested.empty() && fail_counter > 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue