diff options
| -rw-r--r-- | vulkan/libvulkan/layers_extensions.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/vulkan/libvulkan/layers_extensions.cpp b/vulkan/libvulkan/layers_extensions.cpp index 51a26a134b..522d771d45 100644 --- a/vulkan/libvulkan/layers_extensions.cpp +++ b/vulkan/libvulkan/layers_extensions.cpp @@ -63,6 +63,7 @@ struct LayerLibrary { : path(path_), dlhandle(nullptr), refcount(0) {} bool Open(); + void Close(); std::string path; void* dlhandle; @@ -84,6 +85,15 @@ bool LayerLibrary::Open() { return true; } +void LayerLibrary::Close() { + if (--refcount == 0) { + ALOGV("Closing library %s", path.c_str()); + dlclose(dlhandle); + dlhandle = nullptr; + } + ALOGV("Refcount on destruction is %zu", refcount); +} + std::mutex g_library_mutex; std::vector<LayerLibrary> g_layer_libraries; std::vector<Layer> g_instance_layers; @@ -391,12 +401,7 @@ LayerRef::~LayerRef() { if (layer_) { LayerLibrary& library = g_layer_libraries[layer_->library_idx]; std::lock_guard<std::mutex> lock(g_library_mutex); - if (--library.refcount == 0) { - ALOGV("Closing library %s", library.path.c_str()); - dlclose(library.dlhandle); - library.dlhandle = nullptr; - } - ALOGV("Refcount on destruction is %zu", library.refcount); + library.Close(); } } |