File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change
1
+ # Unreleased
2
+ - [ fixed] Fixed an intermittent crash if ` ListenerRegistration::Remove() ` was
3
+ invoked concurrently (#10065 ).
4
+
1
5
# 9.4.0
2
6
- [ fixed] Fixed a crash during app start (#9985 , #10018 ).
3
7
Original file line number Diff line number Diff line change 22
22
#include " Firestore/core/src/core/firestore_client.h"
23
23
#include " Firestore/core/src/core/query_listener.h"
24
24
#include " Firestore/core/src/core/view_snapshot.h"
25
+ #include " absl/synchronization/mutex.h"
25
26
26
27
namespace firebase {
27
28
namespace firestore {
@@ -38,6 +39,8 @@ QueryListenerRegistration::QueryListenerRegistration(
38
39
}
39
40
40
41
void QueryListenerRegistration::Remove () {
42
+ absl::MutexLock lock (&mutex_);
43
+
41
44
auto async_listener = async_listener_.lock ();
42
45
if (async_listener) {
43
46
async_listener->Mute ();
Original file line number Diff line number Diff line change 21
21
22
22
#include " Firestore/core/src/api/listener_registration.h"
23
23
#include " Firestore/core/src/core/core_fwd.h"
24
+ #include " absl/base/thread_annotations.h"
25
+ #include " absl/synchronization/mutex.h"
24
26
25
27
namespace firebase {
26
28
namespace firestore {
@@ -44,14 +46,17 @@ class QueryListenerRegistration : public ListenerRegistration {
44
46
void Remove () override ;
45
47
46
48
private:
49
+ absl::Mutex mutex_;
50
+
47
51
/* * The client that was used to register this listen. */
48
- std::shared_ptr<core::FirestoreClient> client_;
52
+ std::shared_ptr<core::FirestoreClient> client_ ABSL_GUARDED_BY (mutex_) ;
49
53
50
54
/* * The async listener that is used to mute events synchronously. */
51
- std::weak_ptr<core::AsyncEventListener<core::ViewSnapshot>> async_listener_;
55
+ std::weak_ptr<core::AsyncEventListener<core::ViewSnapshot>> async_listener_
56
+ ABSL_GUARDED_BY (mutex_);
52
57
53
58
/* * The internal QueryListener that can be used to unlisten the query. */
54
- std::weak_ptr<core::QueryListener> query_listener_;
59
+ std::weak_ptr<core::QueryListener> query_listener_ ABSL_GUARDED_BY (mutex_) ;
55
60
};
56
61
57
62
} // namespace api
You can’t perform that action at this time.
0 commit comments