Skip to content

Commit

Permalink
Merge d0681c9 into 26075af
Browse files Browse the repository at this point in the history
  • Loading branch information
dconeybe authored Aug 3, 2022
2 parents 26075af + d0681c9 commit d329277
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 89 deletions.
4 changes: 4 additions & 0 deletions Firestore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Unreleased
- [fixed] Fixed an intermittent crash if `ListenerRegistration::Remove()` was
invoked concurrently (#10065).

# 9.4.0
- [fixed] Fixed a crash during app start (#9985, #10018).

Expand Down
3 changes: 3 additions & 0 deletions Firestore/core/src/api/query_listener_registration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "Firestore/core/src/core/firestore_client.h"
#include "Firestore/core/src/core/query_listener.h"
#include "Firestore/core/src/core/view_snapshot.h"
#include "absl/synchronization/mutex.h"

namespace firebase {
namespace firestore {
Expand All @@ -38,6 +39,8 @@ QueryListenerRegistration::QueryListenerRegistration(
}

void QueryListenerRegistration::Remove() {
absl::MutexLock lock(&mutex_);

auto async_listener = async_listener_.lock();
if (async_listener) {
async_listener->Mute();
Expand Down
11 changes: 8 additions & 3 deletions Firestore/core/src/api/query_listener_registration.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "Firestore/core/src/api/listener_registration.h"
#include "Firestore/core/src/core/core_fwd.h"
#include "absl/base/thread_annotations.h"
#include "absl/synchronization/mutex.h"

namespace firebase {
namespace firestore {
Expand All @@ -44,14 +46,17 @@ class QueryListenerRegistration : public ListenerRegistration {
void Remove() override;

private:
absl::Mutex mutex_;

/** The client that was used to register this listen. */
std::shared_ptr<core::FirestoreClient> client_;
std::shared_ptr<core::FirestoreClient> client_ ABSL_GUARDED_BY(mutex_);

/** The async listener that is used to mute events synchronously. */
std::weak_ptr<core::AsyncEventListener<core::ViewSnapshot>> async_listener_;
std::weak_ptr<core::AsyncEventListener<core::ViewSnapshot>> async_listener_
ABSL_GUARDED_BY(mutex_);

/** The internal QueryListener that can be used to unlisten the query. */
std::weak_ptr<core::QueryListener> query_listener_;
std::weak_ptr<core::QueryListener> query_listener_ ABSL_GUARDED_BY(mutex_);
};

} // namespace api
Expand Down
1 change: 0 additions & 1 deletion scripts/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ python --version
"${top_dir}/scripts/check_copyright.sh"
"${top_dir}/scripts/check_test_inclusion.py"
"${top_dir}/scripts/check_imports.swift"
"${top_dir}/scripts/check_firestore_core_api_absl.py"

# Google C++ style
lint_cmd=("${top_dir}/scripts/check_lint.py")
Expand Down
85 changes: 0 additions & 85 deletions scripts/check_firestore_core_api_absl.py

This file was deleted.

0 comments on commit d329277

Please sign in to comment.