From f59a400b27ff4da933812d36da7c9a67e34ead10 Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Thu, 21 Sep 2017 10:30:02 +0900 Subject: [PATCH] Changed cur classid path and initialize Change-Id: Ib7c6bd5ce363a8079750e66943d287e86224e5c6 Signed-off-by: hyunuktak --- packaging/stc-manager.spec | 2 +- src/helper/helper-net-cls.c | 19 ++++++++++++++++++- src/helper/helper-net-cls.h | 5 +---- src/monitor/stc-monitor.c | 5 ++++- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index 7979283..4a256b3 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.0.33 +Version: 0.0.34 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/helper/helper-net-cls.c b/src/helper/helper-net-cls.c index 0f2ae30..ef5e4b3 100755 --- a/src/helper/helper-net-cls.c +++ b/src/helper/helper-net-cls.c @@ -26,7 +26,7 @@ #include "helper-file.h" #include "helper-net-cls.h" -#define CUR_CLASSID_PATH "/tmp/cur_classid" +#define CUR_CLASSID_PATH "/var/lib/stc/cur_classid" #define CLASSID_FILE_NAME "net_cls.classid" typedef GArray task_classid_array; @@ -85,6 +85,23 @@ static uint32_t __get_classid_from_cgroup(const char *cgroup, return classid; } +stc_error_e init_current_classid(void) +{ + int ret = 0; + struct stat stat_buf; + + if (stat(STC_CGROUP_NETWORK, &stat_buf) != 0) { + uint32_t classid = STC_RESERVED_CLASSID_MAX; + ret = fwrite_uint(CUR_CLASSID_PATH, classid); + if (ret < 0) { + STC_LOGE("Can not init current classid"); + return STC_ERROR_FAIL; + } + } + + return STC_ERROR_NONE; +} + uint32_t get_classid_by_app_id(const char *app_id, int create) { int ret = 0; diff --git a/src/helper/helper-net-cls.h b/src/helper/helper-net-cls.h index 24cd993..d27a5b2 100755 --- a/src/helper/helper-net-cls.h +++ b/src/helper/helper-net-cls.h @@ -33,10 +33,7 @@ enum { typedef GArray int_array; -/** - * @desc Get appid from classid task table. At present it is package name. - */ -char *get_app_id_by_pid(const pid_t pid); +stc_error_e init_current_classid(void); /** * @desc take classid from net_cls cgroup by appid diff --git a/src/monitor/stc-monitor.c b/src/monitor/stc-monitor.c index 734620b..fc7b7bb 100755 --- a/src/monitor/stc-monitor.c +++ b/src/monitor/stc-monitor.c @@ -1500,6 +1500,7 @@ static stc_error_e __process_update_background(void) return STC_ERROR_NONE; } +#if 0 static void __excn_hash_foreach_print(gpointer key, gpointer value, gpointer data) { @@ -1510,7 +1511,6 @@ static void __excn_hash_foreach_print(gpointer key, gpointer value, process_name, exe_type); } -#if 0 static void __excn_hash_printall(void) { g_hash_table_foreach(g_system->excns_hash, @@ -1573,6 +1573,9 @@ stc_error_e stc_monitor_init(void) ret_value_msg_if(system == NULL, STC_ERROR_OUT_OF_MEMORY, "stc_system_s malloc fail!"); + /* initializing current classid */ + init_current_classid(); + /* initializing cgroups */ cgroup_init(); -- 2.7.4