Code cleanup and Add missing flag (#257)
author최종헌/Common Platform Lab(SR)/Engineer/삼성전자 <j-h.choi@samsung.com>
Wed, 8 Jul 2020 08:55:26 +0000 (17:55 +0900)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Wed, 8 Jul 2020 08:55:26 +0000 (17:55 +0900)
Change-Id: I9e882fd196edb192c61641c7394fb18531293401

NativeLauncher/CMakeLists.txt
NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc
NativeLauncher/tool/ni_common.cc
NativeLauncher/util/path_manager.cc
NativeLauncher/util/plugin_manager.cc

index 53cdf861064c023faa443594e71af06495dde729..c23d32566a128415930b48d522334ea42fb9e592 100644 (file)
@@ -249,4 +249,3 @@ INSTALL(FILES inc/ni_common.h DESTINATION ${INCLUDEDIR})
 INSTALL(FILES inc/tac_common.h DESTINATION ${INCLUDEDIR})
 INSTALL(FILES ../dotnet-launcher.pc DESTINATION ${LIBDIR}/pkgconfig)
 INSTALL(FILES dotnet-launcher.info DESTINATION /usr/share/parser-plugins)
-
index 86fbc3c38fd3c4eae2235531170e340e646bef87..dd35e478c1d511bd5f70bdf95e7a1d822f44284f 100644 (file)
@@ -20,7 +20,6 @@
 
 #include <cstring>
 #include <vector>
-#include <sstream>
 #include <glib.h>
 #include <pkgmgr_installer_info.h>
 
@@ -30,6 +29,7 @@
 #define LOG_TAG "DOTNET_INSTALLER_PLUGIN"
 
 bool aotPluginInstalled = false;
+bool aotPluginFinished = false;
 
 extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *appId, GList *list)
 {
@@ -51,7 +51,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
        std::string metaValue = getMetadataValue(std::string(pkgId), AOT_METADATA_KEY);
        if (metaValue.empty()) {
                _ERR("Failed to get metadata from [%s]", pkgId);
-               return 0;
+               return -1;
        }
 
        if (metaValue == METADATA_VALUE) {
@@ -89,13 +89,26 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_REMOVED(const char *pkgId, const char *app
 
 extern "C" int PKGMGR_MDPARSER_PLUGIN_CLEAN(const char *pkgId, const char *appId, GList *list)
 {
-       // it can be call without initializeNICommon()
+       // Can be multiple apps in one package
+       if (aotPluginFinished) {
+               _INFO("AOT plugin already finished(CLEAN)");
+               return 0;
+       }
+       aotPluginFinished = true;
+
        finalizeNICommon();
        return 0;
 }
 
 extern "C" int PKGMGR_MDPARSER_PLUGIN_UNDO(const char *pkgId, const char *appId, GList *list)
 {
+       // Can be multiple apps in one package
+       if (aotPluginFinished) {
+               _INFO("AOT plugin already finished(UNDO)");
+               return 0;
+       }
+       aotPluginFinished = true;
+
        finalizeNICommon();
        return 0;
 }
index 3f73edbb8e31c2aa3dd01a008e349a1bc032bb87..2454ab85f5776c06db04c452f1ddc23493cb5f3f 100644 (file)
@@ -246,7 +246,7 @@ static ni_error_e crossgen(const std::string& dllPath, const std::string& appPat
        }
 
        if (checkNIExistence(dllPath)) {
-               fprintf(stderr, "Already ni file is exist for %s\n", dllPath.c_str());
+               //fprintf(stderr, "Already ni file is exist for %s\n", dllPath.c_str());
                return NI_ERROR_ALREADY_EXIST;
        }
 
@@ -534,7 +534,6 @@ ni_error_e createNIUnderDirs(const std::string rootPaths, DWORD flags)
        }
 
        auto convert = [&rootPaths, flags](const std::string& path, const std::string& filename) {
-
                // if path is symlink, donot generate crossgen
                if (!crossgen(path, rootPaths.c_str(), flags)) {
                        waitInterval();
@@ -577,6 +576,7 @@ ni_error_e createNIUnderDirs(const std::string rootPaths, DWORD flags)
                                                bf::create_symlink(originNIPath, symNIPath);
                                                copySmackAndOwnership(symPath.c_str(), symNIPath.c_str(), true);
                                                fprintf(stdout, "%s symbolic link file generated successfully.\n", symNIPath.c_str());
+                                               _INFO("%s symbolic link file generated successfully.", symNIPath.c_str());
                                        }
                                }
                        } catch (const bf::filesystem_error& error) {
index 250f6fbb1db5edba311bf31c8e97fbb91679999a..072db9e43c39f5c42b8f251d5a405a1d6a420a32 100644 (file)
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <vconf.h>
 
 #include <iterator>
 #include <sstream>
-#include <vconf.h>
 #include <fstream>
 
 #include "utils.h"
@@ -225,9 +225,8 @@ const std::string& PathManager::getAppNIPaths()
        return appNIPaths;
 }
 
-// return native dll searching paths for app 
+// return native dll searching paths for app
 const std::string& PathManager::getNativeDllSearchingPaths()
 {
        return nativeDllSearchingPaths;
 }
-
index d0e829ea636a975f5c5bc3ad7b3d9ce0d56cc775..a797ced17c1c6a8d5b6697d325ed49af50231bc9 100644 (file)
@@ -37,6 +37,8 @@ int initializePluginManager(const char* appType)
                        __pluginFunc = (PluginFunc*)calloc(sizeof(PluginFunc), 1);
                        if (!__pluginFunc) {
                                _ERR("fail to allocate memory for plugin function structure");
+                               dlclose(__pluginLib);
+                               __pluginLib = NULL;
                                return -1;
                        }
                        __pluginFunc->initialize = (plugin_initialize_ptr)dlsym(__pluginLib, "plugin_initialize");
@@ -62,7 +64,11 @@ int initializePluginManager(const char* appType)
 
 void finalizePluginManager()
 {
+       if (!initializedPluginManager)
+               return;
+
        _INFO("Plugin manager finalize called");
+
        if (__pluginFunc) {
                free(__pluginFunc);
                __pluginFunc = NULL;