if (ret.IsError()) {
return ret;
}
+ // The variable used to determine if double mutex-locking is needed.
+ auto to_process_cached = to_process_;
{
// All props should be fetched synchronously, but sync function does not work
std::lock_guard<std::mutex> lock_to_process(sim_to_process_mutex_);
LoggerE("Failed getting iccid: %d", result);
}
}
- // prevent returning not filled result
- std::lock_guard<std::mutex> lock_sim(sim_info_mutex_);
+ // Here, the double mutex-locking may hang the application (thread) forever.
+ // This happens when none of above (4) getters succeeds (the to_process_ variable is not
+ // incremented).
+ // Usually, we would return and report an error, but the getPropertyValue and
+ // getPropertyValueArray methods do not invoke errorCallback with proper error type, thus silent
+ // error will be reported.
+ if (to_process_cached != to_process_) {
+ // Try to lock and wait for unlocking the sim_info_mutex_ by all registered callbacks.
+ std::lock_guard<std::mutex> lock_sim(sim_info_mutex_);
+ }
// result will come from callbacks
return PlatformResult(ErrorCode::NO_ERROR);
}