SENSYS browser crash issue fixed. 04/136104/4
authordohyunglim <delight.lim@samsung.com>
Wed, 28 Jun 2017 05:47:12 +0000 (05:47 +0000)
committerdohyunglim <delight.lim@samsung.com>
Thu, 29 Jun 2017 07:34:29 +0000 (07:34 +0000)
Change-Id: I03b500d9bbb057f7ff999b0a772a38306176cdfd
Signed-off-by: dohyunglim <delight.lim@samsung.com>
core/Logger/Logger.cpp
core/ServiceManager/ServiceLib.cpp
core/Tools/EflTools.cpp
core/main.cpp

index 12a1a79..96c1e9b 100755 (executable)
@@ -91,8 +91,15 @@ std::string Logger::getProjectName() const {
 void Logger::init() {
        std::vector<std::shared_ptr<AbstractLogger> >::iterator it =
                        m_loggers.begin(), end = m_loggers.end();
-       for (; it != end; ++it) {
-               (*it)->init();
+       int count = std::distance(it, end);
+       if (count > 0) {
+               if ((*it) != nullptr) {
+                       for (; it != end; ++it) {
+                               (*it)->init();
+                       }
+               }
+       } else {
+               return;
        }
 }
 
@@ -100,8 +107,15 @@ void Logger::log(const std::string &msg, bool errorFlag,
                LoggerLevel ) {
        std::vector<std::shared_ptr<AbstractLogger> >::iterator it =
                        m_loggers.begin(), end = m_loggers.end();
-       for (; it != end; ++it) {
-               (*it)->log(timeStamp(), m_tag, msg, errorFlag);
+       int count = std::distance(it, end);
+       if (count > 0) {
+               if ((*it) != nullptr) {
+                       for (; it != end; ++it) {
+                               (*it)->log(timeStamp(), m_tag, msg, errorFlag);
+                       }
+               }
+       } else {
+               return;
        }
 }
 
@@ -141,18 +155,13 @@ int Logger::registerLogger(AbstractLogger *l) {
 }
 
 std::string Logger::timeStamp() {
-        time_t initializer = time(NULL);
         struct tm b;
-        if(localtime_r(&initializer,&b)==NULL){
-            return std::string("");
-        }
-
         struct timeval detail_time;
-        gettimeofday(&detail_time,NULL);
+        gettimeofday(&detail_time, NULL);
 
         char buf[80];
 //     strftime(buf, sizeof(buf), "%d/%m/%y,%T ", brokenTime, detail_time.tv_usec/1000);
-        snprintf(buf,  sizeof(buf),"[%d/%d/%d,%d:%d:%d.%ld]", b.tm_year, b.tm_mon, b.tm_mday, b.tm_hour, b.tm_min, b.tm_sec, detail_time.tv_usec/1000);
+        snprintf(buf, sizeof(buf), "[%d/%d/%d,%d:%d:%d.%ld]", b.tm_year, b.tm_mon, b.tm_mday, b.tm_hour, b.tm_min, b.tm_sec, detail_time.tv_usec/1000);
         return std::string(buf);
 }
 
index ab9a9c5..1808c3c 100755 (executable)
@@ -26,7 +26,7 @@ namespace core
 
 ServiceLib::ServiceLib(const std::string& libraryFile)
     : libraryFile(libraryFile)
-    , pHnd(0,0)
+    , pHnd(0, 0)
 {
     load();
 }
@@ -39,26 +39,25 @@ ServiceLib::~ServiceLib()
 void ServiceLib::load()
 {
 
-    int flags=0;
+    int flags = 0;
     flags = //RTLD_NOW     //resolve all symbols before dlopen returns
             RTLD_LAZY       //resolve sybols on ussage - fixes problem with cross linikg services.
             | RTLD_GLOBAL | RTLD_DEEPBIND; //export or sybols to be used by other libraries.
 
     pHnd = unique_library_ptr(dlopen(libraryFile.c_str(), flags), dlclose);
-    if(!pHnd){
-        throw std::runtime_error(std::string(__PRETTY_FUNCTION__) + "Library loading error:" + dlerror());
+    if (!pHnd) {
+        throw std::runtime_error(std::string(__PRETTY_FUNCTION__));
     }
 }
 
 FunctionPointer ServiceLib::resolveSymbol(const char* symbol)
 {
-    FunctionPointer address = reinterpret_cast<FunctionPointer>(dlsym(pHnd.get(),symbol));
-    if (!address){
+    FunctionPointer address = reinterpret_cast<FunctionPointer>(dlsym(pHnd.get(), symbol));
+    if (!address) {
         throw std::runtime_error(std::string(__PRETTY_FUNCTION__)
                                 + "Cannot resolve symbol \""
                                 + symbol + "\" in "
-                                + libraryFile
-                                + ":" + dlerror());
+                                + libraryFile);
     }
     return address;
 }
index 90b1cd9..cbedd09 100755 (executable)
@@ -136,14 +136,15 @@ Elm_Entry_Filter_Limit_Size* setEntryLimit(Evas_Object* entry, bool standard_ent
 {
     Elm_Entry_Filter_Limit_Size* limitFilterData =
         static_cast<Elm_Entry_Filter_Limit_Size*>(calloc(1, sizeof(Elm_Entry_Filter_Limit_Size)));
-    limitFilterData->max_char_count = boost::any_cast<int>(config::Config::getInstance().get(
-        standard_entry ? "ENTRY_MAXCHAR" : "URL_MAXCHAR"));
-    limitFilterData->max_byte_count = 0;
+    if (limitFilterData) {
+        limitFilterData->max_char_count = boost::any_cast<int>(config::Config::getInstance().get(
+            standard_entry ? "ENTRY_MAXCHAR" : "URL_MAXCHAR"));
+        limitFilterData->max_byte_count = 0;
 
-    elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, limitFilterData);
-
-    evas_object_smart_callback_add(entry, "maxlength,reached", _entry_maxlength_reached, limitFilterData);
+        elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, limitFilterData);
 
+        evas_object_smart_callback_add(entry, "maxlength,reached", _entry_maxlength_reached, limitFilterData);
+    }
     return limitFilterData;
 }
 
index 2e1a147..8f45929 100755 (executable)
@@ -121,7 +121,7 @@ static void app_control(app_control_h app_control, void* app_data)
     /* to test this functionality please use aul_test command on target:
      *  $aul_test org.tizen.browser __APP_SVC_URI__ <http://full.url.com/>
      */
-    BROWSER_LOGD("%s app_control_h=%p\n", __func__,app_control);
+    BROWSER_LOGD("%s app_control_h=%p\n", __func__, app_control);
 
     char *operation = NULL;
     char *request_uri = NULL;
@@ -131,19 +131,10 @@ static void app_control(app_control_h app_control, void* app_data)
     char *instance_id = NULL;
     char *push_data = NULL;
 
-    if (app_control_get_operation(app_control, &operation) != APP_CONTROL_ERROR_NONE) {
-        BROWSER_LOGD("get app_control operation failed");
-        return;
-    }
-
-    if (app_control_get_uri(app_control, &request_uri) != APP_CONTROL_ERROR_NONE)
-        BROWSER_LOGD("get app_control uri failed");
-
-    if (app_control_get_mime(app_control, &request_mime_type) != APP_CONTROL_ERROR_NONE)
-        BROWSER_LOGD("get app_control mime failed");
-
-    if (app_control_get_caller(app_control, &request_caller) != APP_CONTROL_ERROR_NONE)
-        BROWSER_LOGD("get app_control caller failed");
+    app_control_get_operation(app_control, &operation);
+    app_control_get_uri(app_control, &request_uri);
+    app_control_get_mime(app_control, &request_mime_type);
+    app_control_get_caller(app_control, &request_caller);
 
     BROWSER_LOGD("operation = [%s], request_uri = [%s], request_caller = [%s] request_mime_type = [%s]"
             , operation, request_uri, request_caller, request_mime_type);
@@ -153,7 +144,7 @@ static void app_control(app_control_h app_control, void* app_data)
     std::string inst_id;
     std::string pushData;
 
-    if((operation && !strcmp(operation, APP_CONTROL_OPERATION_VIEW)) && (request_uri != NULL)) {
+    if ((operation && !strcmp(operation, APP_CONTROL_OPERATION_VIEW)) && (request_uri != NULL)) {
         if (request_uri) {
             if (!strncmp(request_uri, "/opt/", strlen("/opt/"))) {
                 uri = std::string("file://") + uri;
@@ -161,37 +152,30 @@ static void app_control(app_control_h app_control, void* app_data)
         }
     }
 
-    if (app_control_get_extra_data(app_control, "search", &search_keyword) == APP_CONTROL_ERROR_NONE) {
-        BROWSER_LOGD("search keyword launching");
+    app_control_get_extra_data(app_control, "search", &search_keyword);
+    app_control_get_instance_id(app_control, &instance_id);
+    app_control_get_extra_data(app_control, "push_data", &push_data);
 
-        if (search_keyword) {
-            uri=std::string(search_keyword);
-            free(search_keyword);
-        }
+    if (search_keyword) {
+        uri = std::string(search_keyword);
+        free(search_keyword);
     }
 
-    if (app_control_get_instance_id(app_control, &instance_id) == APP_CONTROL_ERROR_NONE) {
-        BROWSER_LOGD("get instance id %s", instance_id);
-        if (instance_id) {
-            inst_id=std::string(instance_id);
-            free(instance_id);
-        }
+    if (instance_id) {
+        inst_id = std::string(instance_id);
+        free(instance_id);
     }
 
-    if (app_control_get_extra_data(app_control, "push_data", &push_data) == APP_CONTROL_ERROR_NONE) {
-        BROWSER_LOGD("get push data %s", push_data);
-        if (push_data) {
-            pushData=std::string(push_data);
-            free(push_data);
-        }
+    if (push_data) {
+        pushData = std::string(push_data);
+        free(push_data);
     }
 
     if ((operation && !strcmp(operation, APP_CONTROL_OPERATION_SEARCH )) &&
     ((app_control_get_extra_data(app_control, "http://tizen.org/appcontrol/data/keyword", &search_keyword) == APP_CONTROL_ERROR_NONE) ||
     (app_control_get_extra_data(app_control, APP_CONTROL_DATA_TEXT, &search_keyword) == APP_CONTROL_ERROR_NONE))) {
-        BROWSER_LOGD("APP_CONTROL_OPERATION_SEARCH");
         if (search_keyword) {
-            uri=std::string(search_keyword);
+            uri = std::string(search_keyword);
             free(search_keyword);
         }
     }
@@ -202,11 +186,11 @@ static void app_control(app_control_h app_control, void* app_data)
     free(request_caller);
     free(operation);
 
-    if(inst_id.empty()) {
-        inst_id="browser0";
+    if (inst_id.empty()) {
+        inst_id = "browser0";
     }
-    std::string pwa_id="--browser-instance-id="+inst_id;
-    BROWSER_LOGD("+++Set Instance-ID=%s",pwa_id.c_str());
+    std::string pwa_id = "--browser-instance-id="+inst_id;
+    BROWSER_LOGD("+++Set Instance-ID=%s", pwa_id.c_str());
     browser_argv.push_back(const_cast<char*>(pwa_id.c_str()));
     ewk_set_arguments(browser_argv.size(), browser_argv.data());
 
@@ -219,8 +203,9 @@ static void app_control(app_control_h app_control, void* app_data)
     evas_object_show((*bd)->getMainWindow().get());
     elm_win_activate((*bd)->getMainWindow().get());
 
-    if (appcore_flush_memory() == -1)
-        BROWSER_LOGW("[%s] appcore_flush_memory error!", __PRETTY_FUNCTION__);
+    if (appcore_flush_memory() == -1) {
+       return;
+    }
 }
 
 static void app_pause(void* app_data){
@@ -271,8 +256,8 @@ int main(int argc, char* argv[])try
 //#endif
 
        BROWSER_LOGD("BROWSER IS SAYING HELLO");
-       BROWSER_LOGD("BROWSER TAG: %s",tizen_browser::logger::Logger::getInstance().getLogTag().c_str());
-       BROWSER_LOGD("BROWSER REGISTERED LOGGERS COUNT: %d",tizen_browser::logger::Logger::getInstance().getLoggersCount());
+       BROWSER_LOGD("BROWSER TAG: %s", tizen_browser::logger::Logger::getInstance().getLogTag().c_str());
+       BROWSER_LOGD("BROWSER REGISTERED LOGGERS COUNT: %d", tizen_browser::logger::Logger::getInstance().getLoggersCount());
 
     setenv("COREGL_FASTPATH", "1", 1);