From 078d60ab929ca7ba50ba9e7de5745456c6114352 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 15 Jul 2014 12:35:57 -0400 Subject: Fixed bug with TCP. Don't increment nonce if packet was discarded instead of being sent. --- toxcore/TCP_client.c | 10 +++++----- toxcore/TCP_server.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'toxcore') diff --git a/toxcore/TCP_client.c b/toxcore/TCP_client.c index bc1b7ff4..2a2289b2 100644 --- a/toxcore/TCP_client.c +++ b/toxcore/TCP_client.c @@ -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))) return -1; - increment_nonce(con->sent_nonce); - len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL); - if ((unsigned int)len == sizeof(packet)) - return 1; - if (len <= 0) return 0; + increment_nonce(con->sent_nonce); + + if ((unsigned int)len == sizeof(packet)) + return 1; + memcpy(con->last_packet, packet, length); con->last_packet_length = sizeof(packet); con->last_packet_sent = len; diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index 7487ad4f..6c0133dd 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c @@ -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))) return -1; - increment_nonce(con->sent_nonce); - len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL); - if ((unsigned int)len == sizeof(packet)) - return 1; - if (len <= 0) return 0; + increment_nonce(con->sent_nonce); + + if ((unsigned int)len == sizeof(packet)) + return 1; + memcpy(con->last_packet, packet, length); con->last_packet_length = sizeof(packet); con->last_packet_sent = len; -- cgit v1.2.3