Find the fault package from log file. 51/15951/1 accepted/tizen/generic accepted/tizen/generic/20140226.072408 submit/tizen/20140226.000750
authorSung-jae Park <nicesj.park@samsung.com>
Fri, 31 Jan 2014 15:44:46 +0000 (00:44 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Fri, 31 Jan 2014 15:44:46 +0000 (00:44 +0900)
if it is available.

The data-provider-slave will leave the fault log if it finds a "SO" filename from the siganl handler.
And then if the master catches abnormal termination of slave provider, the master will try to open a
slave's fault log file. if it founds, the master will get the so filename from a log file.
and find the lbid using livebox-service API.

Previously, the master could not find the lbid correctly because of the old style code.
This patch will find the lbid from the DB.

*lbid = livebox Id (aka. dynamic box id)

Change-Id: Idc9ea93bb05c2059d8717385c5610a8ed2f8c22b

packaging/data-provider-master.spec
src/fault_manager.c

index 776037c..b0cf928 100644 (file)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes
-Version: 0.34.0
+Version: 0.34.1
 Release: 1
 Group: HomeTF/Livebox
 License: Flora
index adf8621..1512814 100644 (file)
@@ -24,6 +24,7 @@
 #include <packet.h>
 #include <dlog.h>
 #include <livebox-errno.h>
+#include <livebox-service.h>
 
 #include "util.h"
 #include "debug.h"
@@ -75,11 +76,9 @@ static void clear_log_file(struct slave_node *slave)
 
 static char *check_log_file(struct slave_node *slave)
 {
-       char pkgname[BUFSIZ];
-       const char *pattern = "liblive-";
+       char libexec[BUFSIZ];
        char *ptr;
        FILE *fp;
-       int i;
        char filename[BUFSIZ];
 
        snprintf(filename, sizeof(filename), "%s/slave.%d", SLAVE_LOG_PATH, slave_pid(slave));
@@ -89,35 +88,27 @@ static char *check_log_file(struct slave_node *slave)
                return NULL;
        }
 
-       ptr = fgets(pkgname, sizeof(pkgname), fp);
+       ptr = fgets(libexec, sizeof(libexec), fp);
        if (fclose(fp) != 0) {
                ErrPrint("fclose: %s\n", strerror(errno));
        }
 
-       if (ptr != pkgname) {
+       if (ptr != libexec) {
                ErrPrint("Invalid log\n");
                return NULL;
        }
 
-       for (i = 0; pattern[i] && (pattern[i] == pkgname[i]); i++); /*!< Check pattern of filename */
-       if (strlen(pattern) != i) {
-               ErrPrint("Pattern is not matched: %d\n", i);
-               return NULL;
-       }
-
-       ptr = pkgname + i;
-       i = strlen(ptr) - 3; /* Skip the ".so" */
-       if (i <= 0 || strcmp(ptr + i, ".so")) {
-               ErrPrint("Extension is not matched\n");
-               return NULL;
-       }
-               
-       ptr[i] = '\0'; /*!< Truncate tailer ".so" */
        if (unlink(filename) < 0) {
                ErrPrint("Failed to unlink %s\n", filename);
        }
 
-       return strdup(ptr);
+       ptr = livebox_service_pkgname_by_libexec(libexec);
+       if (!ptr) {
+               ErrPrint("Failed to find the faulted package\n");
+       }
+
+       DbgPrint("Faulted package: %s\n", ptr);
+       return ptr;
 }
 
 HAPI void fault_unicast_info(struct client_node *client, const char *pkgname, const char *filename, const char *func)