From b1b96c4152d9c80807dfd3208d88ad6a8d410996 Mon Sep 17 00:00:00 2001 From: zhangyifan27 Date: Tue, 10 Nov 2020 11:23:08 +0800 Subject: [PATCH] fix --- src/block_service/block_service_manager.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/block_service/block_service_manager.cpp b/src/block_service/block_service_manager.cpp index d5dc176caa..9fc5df161a 100644 --- a/src/block_service/block_service_manager.cpp +++ b/src/block_service/block_service_manager.cpp @@ -42,12 +42,10 @@ block_service_manager::~block_service_manager() block_filesystem *block_service_manager::get_or_create_block_filesystem(const std::string &provider) { - { - zauto_write_lock l(_fs_lock); - auto iter = _fs_map.find(provider); - if (iter != _fs_map.end()) { - return iter->second.get(); - } + zauto_write_lock l(_fs_lock); + auto iter = _fs_map.find(provider); + if (iter != _fs_map.end()) { + return iter->second.get(); } const char *provider_type = dsn_config_get_value_string( @@ -71,12 +69,12 @@ block_filesystem *block_service_manager::get_or_create_block_filesystem(const st if (dsn::ERR_OK == err) { ddebug_f("create block filesystem ok for provider {}", provider); - zauto_write_lock l(_fs_lock); _fs_map.emplace(provider, std::unique_ptr(fs)); } else { derror_f("create block file system err {} for provider {}", std::string(err.to_string()), provider); + delete fs; fs = nullptr; } return fs;