mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed bug with TCP.
Don't increment nonce if packet was discarded instead of being sent.
This commit is contained in:
parent
59821d6a5e
commit
078d60ab92
|
@ -155,16 +155,16 @@ static int write_packet_TCP_secure_connection(TCP_Client_Connection *con, const
|
||||||
if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t)))
|
if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
increment_nonce(con->sent_nonce);
|
|
||||||
|
|
||||||
len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL);
|
len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL);
|
||||||
|
|
||||||
if ((unsigned int)len == sizeof(packet))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
increment_nonce(con->sent_nonce);
|
||||||
|
|
||||||
|
if ((unsigned int)len == sizeof(packet))
|
||||||
|
return 1;
|
||||||
|
|
||||||
memcpy(con->last_packet, packet, length);
|
memcpy(con->last_packet, packet, length);
|
||||||
con->last_packet_length = sizeof(packet);
|
con->last_packet_length = sizeof(packet);
|
||||||
con->last_packet_sent = len;
|
con->last_packet_sent = len;
|
||||||
|
|
|
@ -335,16 +335,16 @@ static int write_packet_TCP_secure_connection(TCP_Secure_Connection *con, const
|
||||||
if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t)))
|
if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
increment_nonce(con->sent_nonce);
|
|
||||||
|
|
||||||
len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL);
|
len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL);
|
||||||
|
|
||||||
if ((unsigned int)len == sizeof(packet))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
increment_nonce(con->sent_nonce);
|
||||||
|
|
||||||
|
if ((unsigned int)len == sizeof(packet))
|
||||||
|
return 1;
|
||||||
|
|
||||||
memcpy(con->last_packet, packet, length);
|
memcpy(con->last_packet, packet, length);
|
||||||
con->last_packet_length = sizeof(packet);
|
con->last_packet_length = sizeof(packet);
|
||||||
con->last_packet_sent = len;
|
con->last_packet_sent = len;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user