summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-07-15 12:35:57 -0400
committerirungentoo <irungentoo@gmail.com>2014-07-15 12:35:57 -0400
commit078d60ab929ca7ba50ba9e7de5745456c6114352 (patch)
tree3b0a29b0d313e3281e4f60db4d6b64b637dbe653 /toxcore
parent59821d6a5ef5b298a66feaaca337e71e9cecab61 (diff)
Fixed bug with TCP.
Don't increment nonce if packet was discarded instead of being sent.
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/TCP_client.c10
-rw-r--r--toxcore/TCP_server.c10
2 files changed, 10 insertions, 10 deletions
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
155 if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t))) 155 if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t)))
156 return -1; 156 return -1;
157 157
158 increment_nonce(con->sent_nonce);
159
160 len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL); 158 len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL);
161 159
162 if ((unsigned int)len == sizeof(packet))
163 return 1;
164
165 if (len <= 0) 160 if (len <= 0)
166 return 0; 161 return 0;
167 162
163 increment_nonce(con->sent_nonce);
164
165 if ((unsigned int)len == sizeof(packet))
166 return 1;
167
168 memcpy(con->last_packet, packet, length); 168 memcpy(con->last_packet, packet, length);
169 con->last_packet_length = sizeof(packet); 169 con->last_packet_length = sizeof(packet);
170 con->last_packet_sent = len; 170 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
335 if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t))) 335 if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t)))
336 return -1; 336 return -1;
337 337
338 increment_nonce(con->sent_nonce);
339
340 len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL); 338 len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL);
341 339
342 if ((unsigned int)len == sizeof(packet))
343 return 1;
344
345 if (len <= 0) 340 if (len <= 0)
346 return 0; 341 return 0;
347 342
343 increment_nonce(con->sent_nonce);
344
345 if ((unsigned int)len == sizeof(packet))
346 return 1;
347
348 memcpy(con->last_packet, packet, length); 348 memcpy(con->last_packet, packet, length);
349 con->last_packet_length = sizeof(packet); 349 con->last_packet_length = sizeof(packet);
350 con->last_packet_sent = len; 350 con->last_packet_sent = len;