summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-10-01 11:44:27 -0400
committerirungentoo <irungentoo@gmail.com>2013-10-01 11:44:27 -0400
commit766cff692f9dc93ef284a214ad4bc6389d6afa76 (patch)
tree7decc654f9da3ca2da0f5ff5ebdd1aee2b6396c1 /toxcore
parent3c7de51ba5dea7192d507f8cc834dfd5a9f64455 (diff)
File sending now works on bad wireless connections.
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/Lossless_UDP.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/toxcore/Lossless_UDP.c b/toxcore/Lossless_UDP.c
index 53cdea09..bdf5cd4c 100644
--- a/toxcore/Lossless_UDP.c
+++ b/toxcore/Lossless_UDP.c
@@ -547,6 +547,8 @@ int discard_packet(Lossless_UDP *ludp, int connection_id)
547 return 0; 547 return 0;
548} 548}
549 549
550#define MAX_SYNC_RATE 20
551
550/* return 0 if data could not be put in packet queue. 552/* return 0 if data could not be put in packet queue.
551 * return 1 if data was put into the queue. 553 * return 1 if data was put into the queue.
552 */ 554 */
@@ -564,6 +566,8 @@ int write_packet(Lossless_UDP *ludp, int connection_id, uint8_t *data, uint32_t
564 return 0; 566 return 0;
565 567
566 if (sendqueue(ludp, connection_id) >= connection->sendbuffer_length && connection->sendbuffer_length != 0) { 568 if (sendqueue(ludp, connection_id) >= connection->sendbuffer_length && connection->sendbuffer_length != 0) {
569 if (sendqueue(ludp, connection_id) > connection->data_rate/MAX_SYNC_RATE)
570 return 0;
567 uint32_t newlen = connection->sendbuffer_length = resize_queue(&connection->sendbuffer, connection->sendbuffer_length, 571 uint32_t newlen = connection->sendbuffer_length = resize_queue(&connection->sendbuffer, connection->sendbuffer_length,
568 connection->sendbuffer_length * 2, connection->successful_sent, connection->sendbuff_packetnum); 572 connection->sendbuffer_length * 2, connection->successful_sent, connection->sendbuff_packetnum);
569 573
@@ -829,7 +833,7 @@ static void adjust_datasendspeed(Connection *connection, uint32_t req_packets)
829 return; 833 return;
830 } 834 }
831 835
832 if (req_packets <= (connection->data_rate / connection->SYNC_rate) / 20 || req_packets <= 1) { 836 if (req_packets <= (connection->data_rate / connection->SYNC_rate) / 5 || req_packets <= 10) {
833 connection->data_rate += (connection->data_rate / 8) + 1; 837 connection->data_rate += (connection->data_rate / 8) + 1;
834 838
835 if (connection->data_rate > connection->sendbuffer_length * connection->SYNC_rate) 839 if (connection->data_rate > connection->sendbuffer_length * connection->SYNC_rate)
@@ -1084,7 +1088,7 @@ static void do_data(Lossless_UDP *ludp)
1084 } 1088 }
1085} 1089}
1086 1090
1087#define MAX_SYNC_RATE 20 1091
1088 1092
1089/* 1093/*
1090 * Automatically adjusts send rates of packets for optimal transmission. 1094 * Automatically adjusts send rates of packets for optimal transmission.