Add listener nullability checks.
This commit is contained in:
parent
784b46a298
commit
68d7353350
@ -468,6 +468,7 @@ static ActorOwn<> get_full_config(DcOption option, Promise<tl_object_ptr<telegra
|
||||
return G()->get_server_time_difference();
|
||||
}
|
||||
void add_auth_key_listener(unique_ptr<Listener> listener) final {
|
||||
CHECK(listener != nullptr);
|
||||
if (listener->notify()) {
|
||||
auth_key_listeners_.push_back(std::move(listener));
|
||||
}
|
||||
@ -493,7 +494,10 @@ static ActorOwn<> get_full_config(DcOption option, Promise<tl_object_ptr<telegra
|
||||
|
||||
std::vector<unique_ptr<Listener>> auth_key_listeners_;
|
||||
void notify() {
|
||||
td::remove_if(auth_key_listeners_, [&](auto &listener) { return !listener->notify(); });
|
||||
td::remove_if(auth_key_listeners_, [&](auto &listener) {
|
||||
CHECK(listener != nullptr);
|
||||
return !listener->notify();
|
||||
});
|
||||
}
|
||||
|
||||
string auth_key_key() const {
|
||||
|
@ -64,6 +64,7 @@ class AuthDataSharedImpl final : public AuthDataShared {
|
||||
}
|
||||
|
||||
void add_auth_key_listener(unique_ptr<Listener> listener) final {
|
||||
CHECK(listener != nullptr);
|
||||
if (listener->notify()) {
|
||||
auto lock = rw_mutex_.lock_write();
|
||||
auth_key_listeners_.push_back(std::move(listener));
|
||||
@ -98,9 +99,11 @@ class AuthDataSharedImpl final : public AuthDataShared {
|
||||
}
|
||||
|
||||
void notify() {
|
||||
auto lock = rw_mutex_.lock_read();
|
||||
|
||||
td::remove_if(auth_key_listeners_, [&](auto &listener) { return !listener->notify(); });
|
||||
auto lock = rw_mutex_.lock_write();
|
||||
td::remove_if(auth_key_listeners_, [&](auto &listener) {
|
||||
CHECK(listener != nullptr);
|
||||
return !listener->notify();
|
||||
});
|
||||
}
|
||||
|
||||
void log_auth_key(const mtproto::AuthKey &auth_key) {
|
||||
|
Loading…
Reference in New Issue
Block a user