mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed possible threading issue.
This commit is contained in:
parent
4a27f61956
commit
475c157d68
|
@ -1168,7 +1168,15 @@ static int handle_data_packet_helper(const Net_Crypto *c, int crypt_connection_i
|
|||
if (add_data_to_buffer(&conn->recv_array, num, &dt) != 0)
|
||||
return -1;
|
||||
|
||||
while (read_data_beg_buffer(&conn->recv_array, &dt) != -1) {
|
||||
|
||||
while (1) {
|
||||
pthread_mutex_lock(&conn->mutex);
|
||||
int ret = read_data_beg_buffer(&conn->recv_array, &dt);
|
||||
pthread_mutex_unlock(&conn->mutex);
|
||||
|
||||
if (ret == -1)
|
||||
break;
|
||||
|
||||
if (conn->connection_data_callback)
|
||||
conn->connection_data_callback(conn->connection_data_callback_object, conn->connection_data_callback_id, dt.data,
|
||||
dt.length);
|
||||
|
|
Loading…
Reference in New Issue
Block a user