mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-26 23:01:05 +08:00
ios: Ensure ScopedLockedFileHandle and UploadReportMac destructor order.
Followup to crrev.com/c/3573184, which did not honor destructor order, leading to the background task releasing before the lock. Bug: 1313555 Change-Id: Ifbd3902964552458b83cfc550f50058067021499 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3591012 Reviewed-by: Joshua Peraza <jperaza@chromium.org> Commit-Queue: Justin Cohen <justincohen@chromium.org>
This commit is contained in:
parent
36c88b15b7
commit
8647761c7d
@ -183,13 +183,14 @@ class CrashReportDatabaseMac : public CrashReportDatabase {
|
||||
//! \brief A private extension of the Report class that maintains bookkeeping
|
||||
//! information of the database.
|
||||
struct UploadReportMac : public UploadReport {
|
||||
#if BUILDFLAG(IS_IOS)
|
||||
//! \brief Obtain a background task assertion while a flock is in use.
|
||||
//! Ensure this is defined first so it is destroyed last.
|
||||
internal::ScopedBackgroundTask ios_background_task{"UploadReportMac"};
|
||||
#endif // BUILDFLAG(IS_IOS)
|
||||
//! \brief Stores the flock of the file for the duration of
|
||||
//! GetReportForUploading() and RecordUploadAttempt().
|
||||
base::ScopedFD lock_fd;
|
||||
#if BUILDFLAG(IS_IOS)
|
||||
//! \brief Obtain a background task assertion while a flock is in use.
|
||||
internal::ScopedBackgroundTask ios_background_task{"UploadReportMac"};
|
||||
#endif // BUILDFLAG(IS_IOS)
|
||||
};
|
||||
|
||||
//! \brief Locates a crash report in the database by UUID.
|
||||
|
@ -93,6 +93,11 @@ Settings::ScopedLockedFileHandle& Settings::ScopedLockedFileHandle::operator=(
|
||||
return *this;
|
||||
}
|
||||
|
||||
Settings::ScopedLockedFileHandle::~ScopedLockedFileHandle() {
|
||||
// Call reset() to ensure the lock is released before the ios_background_task.
|
||||
reset();
|
||||
}
|
||||
|
||||
#endif // BUILDFLAG(IS_IOS)
|
||||
|
||||
namespace internal {
|
||||
|
@ -171,6 +171,8 @@ class Settings {
|
||||
ScopedLockedFileHandle(ScopedLockedFileHandle&& rvalue);
|
||||
ScopedLockedFileHandle& operator=(ScopedLockedFileHandle&& rvalue);
|
||||
|
||||
~ScopedLockedFileHandle();
|
||||
|
||||
private:
|
||||
std::unique_ptr<internal::ScopedBackgroundTask> ios_background_task_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user