Use send_closure_later in on_user_online_timeout_callback to avoid accidental access to MultiTimoeut.

GitOrigin-RevId: b488a006dcbe17d661e18a6e578c08cd070b84ea
This commit is contained in:
levlam 2019-08-29 02:17:52 +03:00
parent 2b382567be
commit cea15d975a
2 changed files with 15 additions and 6 deletions

View File

@ -2353,16 +2353,23 @@ void ContactsManager::on_user_online_timeout_callback(void *contacts_manager_ptr
}
auto contacts_manager = static_cast<ContactsManager *>(contacts_manager_ptr);
UserId user_id(narrow_cast<int32>(user_id_long));
auto u = contacts_manager->get_user(user_id);
send_closure_later(contacts_manager->actor_id(contacts_manager), &ContactsManager::on_user_online_timeout,
UserId(narrow_cast<int32>(user_id_long)));
}
void ContactsManager::on_user_online_timeout(UserId user_id) {
if (G()->close_flag()) {
return;
}
auto u = get_user(user_id);
CHECK(u != nullptr);
LOG(INFO) << "Update " << user_id << " online status to offline";
send_closure_later(
G()->td(), &Td::send_update,
make_tl_object<td_api::updateUserStatus>(user_id.get(), contacts_manager->get_user_status_object(user_id, u)));
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateUserStatus>(user_id.get(), get_user_status_object(user_id, u)));
contacts_manager->update_user_online_member_count(u);
update_user_online_member_count(u);
}
void ContactsManager::on_channel_unban_timeout_callback(void *contacts_manager_ptr, int64 channel_id_long) {

View File

@ -1104,6 +1104,8 @@ class ContactsManager : public Actor {
static void on_channel_unban_timeout_callback(void *contacts_manager_ptr, int64 channel_id_long);
void on_user_online_timeout(UserId user_id);
template <class StorerT>
static void store_link_state(const LinkState &link_state, StorerT &storer);