mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed offline callback being called when connection timed out and died
without ever actually being connected.
This commit is contained in:
parent
62dad7b3f7
commit
b279a4a883
|
@ -224,17 +224,25 @@ static int handle_status(void *object, int number, uint8_t status)
|
|||
if (!friend_con)
|
||||
return -1;
|
||||
|
||||
_Bool call_cb = 0;
|
||||
|
||||
if (status) { /* Went online. */
|
||||
call_cb = 1;
|
||||
friend_con->status = FRIENDCONN_STATUS_CONNECTED;
|
||||
friend_con->ping_lastrecv = unix_time();
|
||||
onion_set_friend_online(fr_c->onion_c, friend_con->onion_friendnum, status);
|
||||
} else { /* Went offline. */
|
||||
friend_con->status = FRIENDCONN_STATUS_CONNECTING;
|
||||
friend_con->crypt_connection_id = -1;
|
||||
if (friend_con->status != FRIENDCONN_STATUS_CONNECTING) {
|
||||
call_cb = 1;
|
||||
friend_con->dht_ping_lastrecv = unix_time();
|
||||
onion_set_friend_online(fr_c->onion_c, friend_con->onion_friendnum, status);
|
||||
}
|
||||
|
||||
friend_con->status = FRIENDCONN_STATUS_CONNECTING;
|
||||
friend_con->crypt_connection_id = -1;
|
||||
}
|
||||
|
||||
if (call_cb) {
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < MAX_FRIEND_CONNECTION_CALLBACKS; ++i) {
|
||||
|
@ -242,6 +250,7 @@ static int handle_status(void *object, int number, uint8_t status)
|
|||
friend_con->callbacks[i].status_callback(friend_con->callbacks[i].status_callback_object,
|
||||
friend_con->callbacks[i].status_callback_id, status);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user