Notify the caution command when the number of instance is warning level 41/172641/13
authorYoungHun Kim <yh8004.kim@samsung.com>
Thu, 15 Mar 2018 04:42:27 +0000 (13:42 +0900)
committerYoungHun Kim <yh8004.kim@samsung.com>
Thu, 29 Mar 2018 23:58:50 +0000 (23:58 +0000)
Change-Id: I81fb172d83dbf2b2637f478b10047d1f150fc0fd

core/include/muse_core.h
server/include/muse_server_config.h
server/src/muse_server_config.c
server/src/muse_server_connection.c

index 09df811e00382d89af55bb04604d2d51d9da0a55..eea83c9b796135e326668f854312fb7c1f4314a7 100644 (file)
@@ -75,6 +75,7 @@ typedef enum {
        MUSE_MODULE_COMMAND_CREATE_SERVER_ACK,
        MUSE_MODULE_COMMAND_RESOURCE_NOT_AVAILABLE,
        MUSE_MODULE_COMMAND_EXTERNAL_STORAGE_STATE_CHANGED,
+       MUSE_MODULE_COMMAND_CREATE_CAUTION,
        MUSE_MODULE_COMMAND_MAX
 } muse_module_command_e;
 
index cdf801cbbb6ec7ad18f57cdb862925f1dc92358f..56c2d813bb49fc224513a404a0c504844fab2a4d 100644 (file)
@@ -42,6 +42,7 @@ extern "C" {
 #define TIMEOUT                                                        "timeout"
 #define DIABLE_WATCHDOG_API_INDEX              "disable_watchdog_api"
 #define MAX_INSTANCE                                   "max_instance"
+#define CAUTION_INSTANCE                                       "caution_instance"
 
 #define DEFAULT_WATCHDOG_MIN_TIMEOUT                           5
 #define DEFAULT_WATCHDOG_MAX_TIMEOUT                           60
@@ -49,6 +50,7 @@ extern "C" {
 #define DEFAULT_MEMORY_LEAK_THRESHOLD                          50000 /* 50MB */
 #define DEFAULT_WATCHDOG_DISABLED_API_INDEX                    -1 /* Watchdog is applied to all dispatcher functions */
 #define DEFAULT_MAX_INSTANCE                                           -1 /* Unlimited */
+#define DEFAULT_CAUTION_INSTANCE                                       -1
 
 typedef struct host_info {
        char *path;
@@ -56,6 +58,7 @@ typedef struct host_info {
        int timeout;
        int disable_watchdog_api;
        int max_instance;
+       int caution_instance;
 } host_info_t;
 
 typedef struct ms_config {
index 37fec6bd61cc06d38bd0db058c1cc04443cea432..0fac0804e606084ed383d6f2798664f8f69acb43 100644 (file)
@@ -160,6 +160,10 @@ static int _ms_config_parser(ms_config_t *conf)
                snprintf(key, MUSE_MSG_LEN_MAX, "%s%s%s", host, INI_PARSER_COLON, MAX_INSTANCE);
                conf->host_infos[host_idx]->max_instance = _ms_config_get_int(conf->muse_dict, key, DEFAULT_MAX_INSTANCE);
 
+               /* caution instance */
+               snprintf(key, MUSE_MSG_LEN_MAX, "%s%s%s", host, INI_PARSER_COLON, CAUTION_INSTANCE);
+               conf->host_infos[host_idx]->caution_instance = _ms_config_get_int(conf->muse_dict, key, DEFAULT_CAUTION_INSTANCE);
+
                host = strtok_r(NULL, INI_PARSER_COMMA, &ptr);
                conf->host_cnt++;
                free(key);
index 0251552e8dddb7b98bfea9d2b6860484529a9e7f..4ab245aeace4b274e5580705d6333aadab59c075 100644 (file)
@@ -33,11 +33,13 @@ static void _ms_connection_module_instance_info(muse_module_h m, ms_connection_t
        muse_module_h connecting_m;
        char pids[MUSE_MSG_LEN_MAX] = {'\0',};
        char pid[MUSE_PARAM_MAX] = {'\0',};
-       int idx, len;
+       int idx, len, caution_instance;
+       ms_config_t *conf = ms_get_instance()->conf;
 
        g_return_if_fail(m);
        g_return_if_fail(connection);
        g_return_if_fail(queue);
+       g_return_if_fail(conf);
 
        len = g_queue_get_length(queue);
 
@@ -53,7 +55,15 @@ static void _ms_connection_module_instance_info(muse_module_h m, ms_connection_t
        }
 
        SECURE_LOGI("total number of module = %d ( %s) - %s %p from pid %d %s client (count %d)",
-               len, pids, connection_cmd[cmd], m, m->pid, ms_get_instance()->conf->host[m->idx], connection->instance_count[m->idx]);
+               len, pids, connection_cmd[cmd], m, m->pid, conf->host[m->idx], connection->instance_count[m->idx]);
+
+       caution_instance = conf->host_infos[m->idx]->caution_instance;
+
+       if (caution_instance != DEFAULT_CAUTION_INSTANCE && connection->instance_count[m->idx] > caution_instance) {
+               LOGI("[MUSE_MODULE_COMMAND_CREATE_CAUTION] player # %d | camera # %d | recorder # %d > %d",
+                       connection->instance_count[MUSE_PLAYER], connection->instance_count[MUSE_CAMERA], connection->instance_count[MUSE_RECORDER], caution_instance);
+               ms_cmd_dispatch(m, MUSE_MODULE_COMMAND_CREATE_CAUTION);
+       }
 }
 
 int ms_connection_register(muse_module_h m)