summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-09-21 22:57:28 -0400
committerirungentoo <irungentoo@gmail.com>2013-09-21 22:57:28 -0400
commit05477f77d35465e7cf9573c51f9b005c7d1dddc3 (patch)
treeec04fd723f3f23fead85231bc0d8718538f303bc
parente36f6c46d199164b52ee2b818c54a672394e71a9 (diff)
Fixed bug.
-rw-r--r--toxcore/Lossless_UDP.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/toxcore/Lossless_UDP.c b/toxcore/Lossless_UDP.c
index fe22f869..25d38b8d 100644
--- a/toxcore/Lossless_UDP.c
+++ b/toxcore/Lossless_UDP.c
@@ -535,10 +535,13 @@ int write_packet(Lossless_UDP *ludp, int connection_id, uint8_t *data, uint32_t
535 535
536 Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection); 536 Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection);
537 537
538 if (connection->status == 0)
539 return 0;
540
538 if (length > MAX_DATA_SIZE || length == 0 || sendqueue(ludp, connection_id) >= MAX_QUEUE_NUM) 541 if (length > MAX_DATA_SIZE || length == 0 || sendqueue(ludp, connection_id) >= MAX_QUEUE_NUM)
539 return 0; 542 return 0;
540 543
541 if (sendqueue(ludp, connection_id) >= connection->sendbuffer_length) { 544 if (sendqueue(ludp, connection_id) >= connection->sendbuffer_length && connection->sendbuffer_length != 0) {
542 uint32_t newlen = connection->sendbuffer_length = resize_queue(&connection->sendbuffer, connection->sendbuffer_length, 545 uint32_t newlen = connection->sendbuffer_length = resize_queue(&connection->sendbuffer, connection->sendbuffer_length,
543 connection->sendbuffer_length * 2, connection->successful_sent, connection->sendbuff_packetnum); 546 connection->sendbuffer_length * 2, connection->successful_sent, connection->sendbuff_packetnum);
544 547
@@ -550,9 +553,6 @@ int write_packet(Lossless_UDP *ludp, int connection_id, uint8_t *data, uint32_t
550 } 553 }
551 554
552 555
553 if (connection->status == 0)
554 return 0;
555
556 uint32_t index = connection->sendbuff_packetnum % connection->sendbuffer_length; 556 uint32_t index = connection->sendbuff_packetnum % connection->sendbuffer_length;
557 memcpy(connection->sendbuffer[index].data, data, length); 557 memcpy(connection->sendbuffer[index].data, data, length);
558 connection->sendbuffer[index].size = length; 558 connection->sendbuffer[index].size = length;