Fix vconf callback function 72/325372/4 accepted/tizen_unified accepted/tizen_unified_x tizen accepted/tizen/unified/20250613.092106 accepted/tizen/unified/x/20250613.100733
authorMinje Ahn <minje.ahn@samsung.com>
Tue, 10 Jun 2025 01:14:12 +0000 (10:14 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Tue, 10 Jun 2025 23:55:33 +0000 (23:55 +0000)
Change-Id: I4f69cba86c05881ca40f1f73d9d3744fcc21213d
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/server/media-server-main.c

index d6a52df39802347c0d0cdbd7f5078aa9f54602f2..202eda510b4b10fb4ff69af231964b3ce05bac2d 100644 (file)
@@ -46,8 +46,6 @@
 
 #define MS_VCONF_KEY_RESET_STATUS "db/media_server/reset_status"
 #define SMARTHUB_RESET_VCONF "db/smarthub/reset/firstscreen"
-
-bool smarthub_reset;
 #endif
 
 GMainLoop *mainloop = NULL;
@@ -87,41 +85,37 @@ static bool __ms_deal_reset_status(void)
        return true;
 }
 
-static void __ms_smarthub_vconf_cb(void *data)
+static void __ms_smarthub_vconf_cb(keynode_t *key, void *user_data)
 {
        int status = 0;
        int scanner_pid = 0;
        uid_t uid = ms_sys_get_uid();
 
-       if (!ms_get_power_off()) {
-               if (!ms_config_get_int(SMARTHUB_RESET_VCONF, &status))
-                       MS_DBG_ERR("Get SMARTHUB_RESET_VCONF failed.");
-
-               MS_DBG_ERR("CURRENT STATUS OF SMARTHUB_RESET_VCONF[%d]", status);
+       if (ms_get_power_off())
+               return;
 
-               smarthub_reset = true;
+       status = vconf_keynode_get_int(key);
+       MS_DBG_ERR("CURRENT STATUS OF SMARTHUB_RESET_VCONF[%d]", status);
+       if (status != 0)
+               return;
 
-               if (status == 0) {
-                       scanner_pid = ms_get_scanner_pid();
+       scanner_pid = ms_get_scanner_pid();
 
-                       /*Kill the running child process*/
-                       if (scanner_pid > 0) {
-                               if (kill(scanner_pid, SIGKILL) < 0) {
-                                       MS_DBG_ERR("kill failed");
-                                       MS_DBG_STRERROR();
-                               }
-                       }
+       if (scanner_pid > 0) {
+               if (kill(scanner_pid, SIGKILL) == 0) {
                        MS_DBG("KILL SCANNER");
-                       MS_DBG_ERR("START SMART HUB RESET");
-                       ms_config_set_int(MS_DB_RESET, 1);
-                       ms_reset_ownerlist();
-                       ms_reset_mediadb(uid);
-                       __ms_update_mediadb(true);
-                       ms_config_set_int(MS_DB_RESET, 0);
-                       MS_DBG_ERR("END SMART HUB RESET");
-                       smarthub_reset = false;
+               } else {
+                       MS_DBG_STRERROR("kill failed");
                }
        }
+
+       MS_DBG_ERR("START SMART HUB RESET");
+       ms_config_set_int(MS_DB_RESET, 1);
+       ms_reset_ownerlist();
+       ms_reset_mediadb(uid);
+       __ms_update_mediadb(true);
+       ms_config_set_int(MS_DB_RESET, 0);
+       MS_DBG_ERR("END SMART HUB RESET");
 }
 #endif
 
@@ -302,13 +296,9 @@ int main(int argc, char **argv)
 static void __ms_add_event_receiver(void)
 {
 #ifdef _USE_TVPD_MODE
-       int err = 0;
-       /*add noti receiver for smart hub reset */
-       err = vconf_notify_key_changed(SMARTHUB_RESET_VCONF, (vconf_callback_fn) __ms_smarthub_vconf_cb, NULL);
-       if (err == -1)
+       if (vconf_notify_key_changed(SMARTHUB_RESET_VCONF, __ms_smarthub_vconf_cb, NULL) == -1)
                MS_DBG_ERR("add call back function for event %s fails", SMARTHUB_RESET_VCONF);
 #else
-       /*set power off callback function*/
        ms_sys_set_poweroff_cb(__power_off_cb, NULL);
 #endif
        ms_sys_set_device_block_event_cb(ms_device_block_changed_cb, NULL);