mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Attempted fix of disconnect when switching from TCP to UDP.
This commit is contained in:
parent
61c20d48aa
commit
0c29c00125
|
@ -501,6 +501,14 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t
|
||||||
int ret = send_packet_tcp_connection(c->tcp_c, conn->connection_number_tcp, data, length);
|
int ret = send_packet_tcp_connection(c->tcp_c, conn->connection_number_tcp, data, length);
|
||||||
pthread_mutex_unlock(&c->tcp_mutex);
|
pthread_mutex_unlock(&c->tcp_mutex);
|
||||||
|
|
||||||
|
pthread_mutex_lock(&conn->mutex);
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
conn->last_tcp_sent = current_time_monotonic();
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&conn->mutex);
|
||||||
|
|
||||||
if (ret == 0 || direct_send_attempt) {
|
if (ret == 0 || direct_send_attempt) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2190,6 +2198,13 @@ static void send_crypto_packets(Net_Crypto *c)
|
||||||
|
|
||||||
unsigned int n_p_pos = conn->last_sendqueue_counter % CONGESTION_LAST_SENT_ARRAY_SIZE;
|
unsigned int n_p_pos = conn->last_sendqueue_counter % CONGESTION_LAST_SENT_ARRAY_SIZE;
|
||||||
conn->last_num_packets_sent[n_p_pos] = packets_sent;
|
conn->last_num_packets_sent[n_p_pos] = packets_sent;
|
||||||
|
|
||||||
|
_Bool direct_connected = 0;
|
||||||
|
crypto_connection_status(c, i, &direct_connected, NULL);
|
||||||
|
|
||||||
|
if (direct_connected && conn->last_tcp_sent + CONGESTION_EVENT_TIMEOUT > temp_time) {
|
||||||
|
/* When switching from TCP to UDP, don't change the packet send rate for CONGESTION_EVENT_TIMEOUT ms. */
|
||||||
|
} else {
|
||||||
long signed int total_sent = 0;
|
long signed int total_sent = 0;
|
||||||
|
|
||||||
//TODO use real delay
|
//TODO use real delay
|
||||||
|
@ -2225,6 +2240,7 @@ static void send_crypto_packets(Net_Crypto *c)
|
||||||
if (conn->packet_send_rate < CRYPTO_PACKET_MIN_RATE) {
|
if (conn->packet_send_rate < CRYPTO_PACKET_MIN_RATE) {
|
||||||
conn->packet_send_rate = CRYPTO_PACKET_MIN_RATE;
|
conn->packet_send_rate = CRYPTO_PACKET_MIN_RATE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,8 @@ typedef struct {
|
||||||
uint64_t direct_lastrecv_timev4; /* The Time at which we last received a direct packet in ms. */
|
uint64_t direct_lastrecv_timev4; /* The Time at which we last received a direct packet in ms. */
|
||||||
uint64_t direct_lastrecv_timev6;
|
uint64_t direct_lastrecv_timev6;
|
||||||
|
|
||||||
|
uint64_t last_tcp_sent; /* Time the last TCP packet was sent. */
|
||||||
|
|
||||||
Packets_Array send_array;
|
Packets_Array send_array;
|
||||||
Packets_Array recv_array;
|
Packets_Array recv_array;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user