[Release] wrt-plugins-common_0.3.108
[framework/web/wrt-plugins-common.git] / src / plugins-api-support / PluginRegistry.cpp
index adf6563..c4bc496 100644 (file)
@@ -31,7 +31,9 @@
 #include <algorithm>
 
 #include <dpl/log/log.h>
+#include <dpl/log/secure_log.h>
 #include <dpl/foreach.h>
+#include <dpl/scope_guard.h>
 
 namespace WrtPluginsApi {
 void PluginRegistry::AddPlugin(const std::string& libraryName,
@@ -87,6 +89,20 @@ void PluginRegistry::UnloadAll()
                 LogError("Error: " << (error != NULL ? error : "unknown"));
                 continue;
             }
+            DPL_SCOPE_EXIT(handle) {
+                if (dlclose(handle) != 0) {
+                    const char* error = dlerror();
+                    if (error != NULL)
+                    {
+                        std::string errstr{error};
+                        _E("%s", errstr.c_str());
+                    }
+                    else
+                    {
+                        _E("unknown error while closing plug-in library");
+                    }
+                }
+            };
 
             ExportedApi* entryPoint =
                 static_cast<ExportedApi*>