[incfs] Fix the mount state callbacks processing
- use a never-existing storage ID as a job key
- order the jobs in the map to not skip them on changes, or,
worse, never hang in a loop
- clear the local callbacks vector before moving to the next
storage ID
- try to resume from the closest place on the next processing
iteration
Bug: 183435580
Test: atest service.incremental_test
Change-Id: I36cd5d30c656bed62c20bd7a7f84fb58046a0933
diff --git a/services/incremental/IncrementalService.h b/services/incremental/IncrementalService.h
index 105d40c..a697305 100644
--- a/services/incremental/IncrementalService.h
+++ b/services/incremental/IncrementalService.h
@@ -95,7 +95,8 @@
#pragma GCC diagnostic pop
static constexpr StorageId kInvalidStorageId = -1;
- static constexpr StorageId kMaxStorageId = std::numeric_limits<int>::max();
+ static constexpr StorageId kMaxStorageId = std::numeric_limits<int>::max() - 1;
+ static constexpr StorageId kAllStoragesId = kMaxStorageId + 1;
static constexpr BootClockTsUs kMaxBootClockTsUs = std::numeric_limits<BootClockTsUs>::max();
@@ -472,7 +473,7 @@
std::mutex mCallbacksLock;
std::unordered_map<std::string, sp<AppOpsListener>> mCallbackRegistered;
- using IfsStateCallbacks = std::unordered_map<StorageId, std::vector<IfsStateCallback>>;
+ using IfsStateCallbacks = std::map<StorageId, std::vector<IfsStateCallback>>;
std::mutex mIfsStateCallbacksLock;
IfsStateCallbacks mIfsStateCallbacks;