From 2645ffe682d2e0b828b15fadab3b5877255e672c Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Sat, 1 Feb 2014 00:44:46 +0900 Subject: [PATCH] Find the fault package from log file. 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 | 2 +- src/fault_manager.c | 31 +++++++++++-------------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index 776037c..b0cf928 100644 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -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 diff --git a/src/fault_manager.c b/src/fault_manager.c index adf8621..1512814 100644 --- a/src/fault_manager.c +++ b/src/fault_manager.c @@ -24,6 +24,7 @@ #include #include #include +#include #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) -- 2.7.4