avoid mixing direct unlocking with lock-holders

Summary:
When using lock-holder objects, it is typically required to conduct all unlocking and relocking through them. That way, the RAII lock-holder does not attempt to unlock an unlocked mutex should the code throw after unlocking but before relocking.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D29238721

fbshipit-source-id: 2403ce8c9e86f96b56a35a456e017486a2854c74
This commit is contained in:
Yedidya Feldblum 2021-06-29 14:36:09 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 7c47420de7
Коммит 77279067f1
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -60,9 +60,9 @@ ComponentDescriptor const &ComponentDescriptorRegistry::at(
auto it = _registryByName.find(unifiedComponentName); auto it = _registryByName.find(unifiedComponentName);
if (it == _registryByName.end()) { if (it == _registryByName.end()) {
mutex_.unlock_shared(); lock.unlock();
providerRegistry_.request(unifiedComponentName.c_str()); providerRegistry_.request(unifiedComponentName.c_str());
mutex_.lock_shared(); lock.lock();
it = _registryByName.find(unifiedComponentName); it = _registryByName.find(unifiedComponentName);