diff options
author | irungentoo <irungentoo@gmail.com> | 2014-12-03 14:22:41 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-12-03 14:22:41 -0500 |
commit | 475c157d68b53e9d6666c678bfb2dc0c2e126216 (patch) | |
tree | 23031311d62428070ae66114c5aa9306e6c69dda /toxcore | |
parent | 4a27f61956559fbdc2e18c66cd57f5de3d9024ea (diff) |
Fixed possible threading issue.
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/net_crypto.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index a813395a..bcb1dc6d 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -1168,7 +1168,15 @@ static int handle_data_packet_helper(const Net_Crypto *c, int crypt_connection_i | |||
1168 | if (add_data_to_buffer(&conn->recv_array, num, &dt) != 0) | 1168 | if (add_data_to_buffer(&conn->recv_array, num, &dt) != 0) |
1169 | return -1; | 1169 | return -1; |
1170 | 1170 | ||
1171 | while (read_data_beg_buffer(&conn->recv_array, &dt) != -1) { | 1171 | |
1172 | while (1) { | ||
1173 | pthread_mutex_lock(&conn->mutex); | ||
1174 | int ret = read_data_beg_buffer(&conn->recv_array, &dt); | ||
1175 | pthread_mutex_unlock(&conn->mutex); | ||
1176 | |||
1177 | if (ret == -1) | ||
1178 | break; | ||
1179 | |||
1172 | if (conn->connection_data_callback) | 1180 | if (conn->connection_data_callback) |
1173 | conn->connection_data_callback(conn->connection_data_callback_object, conn->connection_data_callback_id, dt.data, | 1181 | conn->connection_data_callback(conn->connection_data_callback_object, conn->connection_data_callback_id, dt.data, |
1174 | dt.length); | 1182 | dt.length); |