fix media server crash
authorYong Yeon Kim <yy9875.kim@samsung.com>
Wed, 20 Mar 2013 02:03:18 +0000 (11:03 +0900)
committerYong Yeon Kim <yy9875.kim@samsung.com>
Wed, 20 Mar 2013 02:03:18 +0000 (11:03 +0900)
fix db update routine error
fix bug : crash occur when media_db_update_unsubscribe() is called before media_db_update_subscribe() is called
change parameters of plugin APIs
When timeout happens, reset thumbnail server status
polling socket binding
Change way to send updated path (for N_SE_29040)

12 files changed:
Makefile.am
lib/media-util-ipc.c
lib/media-util-noti.c
packaging/media-server.spec
src/common/media-common-drm.c
src/scanner/include/media-scanner-db-svc.h
src/scanner/media-scanner-db-svc.c
src/scanner/media-scanner-scan.c
src/scanner/media-scanner.c
src/server/media-server-main.c
src/server/media-server-socket.c
src/server/media-server-thumb.c

index 29dea63..716b424 100755 (executable)
@@ -15,11 +15,11 @@ hib_directory = /etc/rc.d/rc5.d
 
 install-data-hook:
        mkdir $(DESTDIR)$(nor_directory) -p
-       ln -s ../init.d/mediasvr S99mediasvr
-       mv ./S99mediasvr $(DESTDIR)$(nor_directory)
+       ln -s ../init.d/mediasvr S46mediasvr
+       mv ./S46mediasvr $(DESTDIR)$(nor_directory)
        mkdir $(DESTDIR)$(hib_directory) -p
-       ln -s ../init.d/mediasvr S99mediasvr
-       mv ./S99mediasvr $(DESTDIR)$(hib_directory)
+       ln -s ../init.d/mediasvr S46mediasvr
+       mv ./S46mediasvr $(DESTDIR)$(hib_directory)
 
 # init.d script
 fmsvcdir = /etc/rc.d/init.d
index bfe49fa..7c0af35 100755 (executable)
@@ -128,6 +128,8 @@ int ms_ipc_create_client_socket(ms_protocol_e protocol, int timeout_sec, int *so
 
 int ms_ipc_create_server_socket(ms_protocol_e protocol, int port, int *sock_fd)
 {
+       int i;
+       bool bind_success = false;
        int sock = -1;
        int n_reuse = 1;
 #ifdef _USE_UDS_SOCKET_
@@ -183,10 +185,18 @@ int ms_ipc_create_server_socket(ms_protocol_e protocol, int port, int *sock_fd)
        serv_addr.sin_addr.s_addr = inet_addr(SERVER_IP);
        serv_addr.sin_port = htons(serv_port);
 #endif
-
        /* Bind to the local address */
-       if (bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
-               MSAPI_DBG_ERR("bind failed : %s", strerror(errno));
+       for (i = 0; i < 20; i ++) {
+               if (bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == 0) {
+                       bind_success = true;
+                       break;
+               }
+               MSAPI_DBG("%d",i);
+               usleep(250000);
+       }
+
+       if (bind_success == false) {
+               MSAPI_DBG_ERR("bind failed : %s %d_", strerror(errno), errno);
                close(sock);
                return MS_MEDIA_ERR_SOCKET_CONN;
        }
index 17b6fb3..b9c1976 100755 (executable)
@@ -71,9 +71,10 @@ __message_filter (DBusConnection *connection, DBusMessage *message, void *user_d
        /* A Ping signal on the com.burtonini.dbus.Signal interface */
        if (dbus_message_is_signal (message, MS_MEDIA_DBUS_INTERFACE, MS_MEDIA_DBUS_NAME)) {
                int i = 0;
+               int current_type = DBUS_TYPE_INVALID;
                DBusError error;
                DBusMessageIter read_iter;
-               DBusBasicValue value[7];
+               DBusBasicValue value[6];
 
                dbus_int32_t item = -1;
                dbus_int32_t pid = 0;
@@ -82,6 +83,8 @@ __message_filter (DBusConnection *connection, DBusMessage *message, void *user_d
                char *update_path = NULL;
                char *uuid = NULL;
                char *mime_type = NULL;
+               void *recevie_path = NULL;
+               int path_len = 0;
 
                dbus_error_init (&error);
                MSAPI_DBG("size [%d]", sizeof(value));
@@ -89,19 +92,28 @@ __message_filter (DBusConnection *connection, DBusMessage *message, void *user_d
 
                /* get data from dbus message */
                dbus_message_iter_init (message, &read_iter);
-               while (dbus_message_iter_get_arg_type (&read_iter)  != DBUS_TYPE_INVALID){
-                       dbus_message_iter_get_basic (&read_iter, &value[i]);
+               while ((current_type = dbus_message_iter_get_arg_type (&read_iter)) != DBUS_TYPE_INVALID){
+                       if (current_type == DBUS_TYPE_ARRAY) {
+                               DBusMessageIter sub;
+                               dbus_message_iter_recurse(&read_iter, &sub);
+                               dbus_message_iter_get_fixed_array(&sub, &recevie_path, &path_len);
+                       } else {
+                               dbus_message_iter_get_basic (&read_iter, &value[i]);
+                               i ++;
+                       }
                        dbus_message_iter_next (&read_iter);
-                       i ++;
                }
 
                item = value[0].i32;
                pid = value[1].i32;
                update_type = value[2].i32;
-               update_path = strdup(value[3].str);
-               if (value[4].str != NULL) uuid = strdup(value[4].str);
-               content_type = value[5].i32;
-               if (value[6].str != NULL) mime_type = strdup(value[6].str);
+               update_path = strndup(recevie_path, path_len);
+               if (value[3].str != NULL) uuid = strdup(value[3].str);
+               content_type = value[4].i32;
+               if (value[5].str != NULL) mime_type = strdup(value[5].str);
+
+               if (item == MS_MEDIA_ITEM_DIRECTORY)
+                       content_type = MS_MEDIA_UNKNOWN;
 
                /* getting data complete */
                user_cb(pid,
@@ -113,6 +125,10 @@ __message_filter (DBusConnection *connection, DBusMessage *message, void *user_d
                                mime_type,
                                userdata);
 
+               MS_SAFE_FREE(update_path);
+               MS_SAFE_FREE(uuid);
+               MS_SAFE_FREE(mime_type);
+
                g_mutex_unlock(noti_mutex);
 
                return DBUS_HANDLER_RESULT_HANDLED;
@@ -130,6 +146,9 @@ int media_db_update_subscribe(db_update_cb user_cb, void *user_data)
 
        if (noti_mutex == NULL) {
                noti_mutex = g_mutex_new();
+               if (noti_mutex == NULL) {
+                       return MS_MEDIA_ERR_ALLOCATE_MEMORY_FAIL;
+               }
        }
 
        if (g_bus == NULL) {
@@ -141,6 +160,8 @@ int media_db_update_subscribe(db_update_cb user_cb, void *user_data)
                if (!g_bus) {
                        MSAPI_DBG ("Failed to connect to the D-BUS daemon: %s", error.message);
                        dbus_error_free (&error);
+                       g_mutex_free(noti_mutex);
+                       noti_mutex = NULL;
                        return MS_MEDIA_ERR_DBUS_GET;
                }
 
@@ -150,6 +171,8 @@ int media_db_update_subscribe(db_update_cb user_cb, void *user_data)
                MS_MALLOC(callback_data, sizeof(noti_callback_data));
                if (callback_data == NULL) {
                        MSAPI_DBG_ERR("MS_MALLOC failed");
+                       g_mutex_free(noti_mutex);
+                       noti_mutex = NULL;
                        return MS_MEDIA_ERR_ALLOCATE_MEMORY_FAIL;
                }
                callback_data->user_callback = user_cb;
@@ -159,6 +182,8 @@ int media_db_update_subscribe(db_update_cb user_cb, void *user_data)
                dbus_bus_add_match (g_bus, MS_MEDIA_DBUS_MATCH_RULE, &error);
                if( !dbus_connection_add_filter (g_bus, __message_filter, callback_data, __free_data_fuction)) {
                        MS_SAFE_FREE(callback_data);
+                       g_mutex_free(noti_mutex);
+                       noti_mutex = NULL;
                        return MS_MEDIA_ERR_DBUS_ADD_FILTER;
                }
                g_data_store = (void *)callback_data;
@@ -169,19 +194,20 @@ int media_db_update_subscribe(db_update_cb user_cb, void *user_data)
 
 int media_db_update_unsubscribe(void)
 {
-       g_mutex_lock(noti_mutex);
+       if (g_bus == NULL) {
+               return MS_MEDIA_ERR_NONE;
+       }
 
-       if (g_bus != NULL) {
-               dbus_connection_remove_filter(g_bus, __message_filter, g_data_store);
+       g_mutex_lock(noti_mutex);
 
-               dbus_connection_unref(g_bus);
+       dbus_connection_remove_filter(g_bus, __message_filter, g_data_store);
+       dbus_connection_unref(g_bus);
 
-               g_bus = NULL;
-       }
+       g_bus = NULL;
 
        g_mutex_unlock(noti_mutex);
 
-       if (noti_mutex) g_mutex_free(noti_mutex);
+       g_mutex_free(noti_mutex);
        noti_mutex = NULL;
 
        return MS_MEDIA_ERR_NONE;
@@ -199,6 +225,8 @@ int media_db_update_send(int pid, /* mandatory */
        DBusMessage *message;
        DBusConnection *bus;
        DBusError error;
+       unsigned char *path_array = NULL;
+       int path_length = strlen(path) + 1;
 
        /* Get a connection to the session bus */
        dbus_error_init (&error);
@@ -209,8 +237,9 @@ int media_db_update_send(int pid, /* mandatory */
                return MS_MEDIA_ERR_DBUS_GET;
        }
 
-       /* Create a new signal on the "MS_DBUS_INTERFACE" interface,
-       * from the object "MS_DBUS_PATH". */
+       path_array = malloc(sizeof(unsigned char) * path_length);
+       memcpy(path_array, path, path_length);
+
        message = dbus_message_new_signal (MS_MEDIA_DBUS_PATH, MS_MEDIA_DBUS_INTERFACE, MS_MEDIA_DBUS_NAME);
        if (message != NULL) {
                if (item == MS_MEDIA_ITEM_FILE) {
@@ -221,7 +250,7 @@ int media_db_update_send(int pid, /* mandatory */
                                                                                DBUS_TYPE_INT32, &item,
                                                                                DBUS_TYPE_INT32, &pid,
                                                                                DBUS_TYPE_INT32, &update_type,
-                                                                               DBUS_TYPE_STRING, &path,
+                                                                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &path_array, path_length,
                                                                                DBUS_TYPE_STRING, &uuid,
                                                                                DBUS_TYPE_INT32, &media_type,
                                                                                DBUS_TYPE_STRING, &mime_type,
@@ -238,7 +267,7 @@ int media_db_update_send(int pid, /* mandatory */
                                                                                DBUS_TYPE_INT32, &item,
                                                                                DBUS_TYPE_INT32, &pid,
                                                                                DBUS_TYPE_INT32, &update_type,
-                                                                               DBUS_TYPE_STRING, &path,
+                                                                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &path_array, path_length,
                                                                                DBUS_TYPE_STRING, &uuid,
                                                                                DBUS_TYPE_INVALID);
                        } else {
@@ -246,13 +275,15 @@ int media_db_update_send(int pid, /* mandatory */
                                                                                DBUS_TYPE_INT32, &item,
                                                                                DBUS_TYPE_INT32, &pid,
                                                                                DBUS_TYPE_INT32, &update_type,
-                                                                               DBUS_TYPE_STRING, &path,
+                                                                               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &path_array, path_length,
                                                                                DBUS_TYPE_INVALID);
                        }
                } else {
                        MSAPI_DBG("this request is wrong");
                }
 
+               MS_SAFE_FREE(path_array);
+
                /* Send the signal */
                dbus_connection_send (bus, message, NULL);
 
index 748e08d..7daf194 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       media-server
 Summary:    File manager service server.
-Version: 0.2.34
+Version: 0.2.39
 Release:    1
 Group:      utils
 License:    Apache License, Version 2.0
@@ -75,8 +75,8 @@ vconftool set -t int file/private/mediaserver/scan_directory "1" -f
 %{_bindir}/media-scanner
 %{_bindir}/mediadb-update
 %attr(755,-,-) %{_sysconfdir}/rc.d/init.d/mediasvr
-/etc/rc.d/rc3.d/S99mediasvr
-/etc/rc.d/rc5.d/S99mediasvr
+/etc/rc.d/rc3.d/S46mediasvr
+/etc/rc.d/rc5.d/S46mediasvr
 /usr/lib/systemd/system/media-server.service
 /usr/lib/systemd/system/multi-user.target.wants/media-server.service
 #License
index 60cca17..27a7fda 100755 (executable)
@@ -66,7 +66,6 @@ ms_get_mime_in_drm_info(const char *path, char *mime)
                MS_DBG_ERR("%s [%d]", path, ret);
                return MS_MEDIA_ERR_DRM_GET_INFO_FAIL;
        } else {
-               MS_DBG_ERR("DRM TYPE  [%d]", file_type);
                /* if a drm file is OMA drm, use DRM API for getting mime information */
                if (file_type == DRM_TYPE_OMA_V1
                || file_type == DRM_TYPE_OMA_V2
@@ -92,7 +91,7 @@ ms_get_mime_in_drm_info(const char *path, char *mime)
 int
 ms_drm_register(const char* path)
 {
-       MS_DBG("THIS IS DRM FILE");
+
        int res = MS_MEDIA_ERR_NONE;
        int ret;
 
index 75d5e14..5854035 100755 (executable)
 
 #include "media-common-types.h"
 
-typedef int (*CHECK_ITEM)(const char*, const char*, char **);
+typedef int (*CHECK_ITEM)(const char*, char **);
 typedef int (*CONNECT)(void**, char **);
 typedef int (*DISCONNECT)(void*, char **);
 typedef int (*CHECK_ITEM_EXIST)(void*, const char*, int, char **);
 typedef int (*INSERT_ITEM_BEGIN)(void*, int, int, int, char **);
 typedef int (*INSERT_ITEM_END)(void*, char **);
-typedef int (*INSERT_ITEM)(void*, const char*, int, const char*, char **);
+typedef int (*INSERT_ITEM)(void*, const char*, int, char **);
 typedef int (*SET_ALL_STORAGE_ITEMS_VALIDITY)(void*, int, int, char **);
 typedef int (*SET_ITEM_VALIDITY_BEGIN)(void*, int, char **);
 typedef int (*SET_ITEM_VALIDITY_END)(void*, char **);
-typedef int (*SET_ITEM_VALIDITY)(void*, const char*, int, const char*, int, char **);
+typedef int (*SET_ITEM_VALIDITY)(void*, const char*, int, int, char **);
 typedef int (*DELETE_ALL_ITEMS_IN_STORAGE)(void*, int, char **);
 typedef int (*DELETE_ALL_INVALID_ITMES_IN_STORAGE)(void*, int, char **);
 typedef int (*UPDATE_BEGIN)(void);
 typedef int (*UPDATE_END)(void);
 typedef int (*SET_FOLDER_ITEM_VALIDITY)(void*, const char*, int, int, char**);
 typedef int (*DELETE_ALL_INVALID_ITEMS_IN_FOLDER)(void*, const char*, char**);
-typedef int (*INSERT_BURST_ITEM)(void *, const char *, int , const char*, char **);
+typedef int (*INSERT_BURST_ITEM)(void *, const char *, int , char **);
 typedef int (*SEND_DIR_UPDATE_NOTI)(void *, const char *, char **);
 
 int
index fba619b..9295840 100755 (executable)
@@ -73,12 +73,12 @@ enum func_list {
 };
 
 static int
-_msc_check_category(const char *path, const char *mimetype, int index)
+_msc_check_category(const char *path, int index)
 {
        int ret;
        char *err_msg = NULL;
 
-       ret = ((CHECK_ITEM)func_array[index][eCHECK])(path, mimetype, &err_msg);
+       ret = ((CHECK_ITEM)func_array[index][eCHECK])(path, &err_msg);
        if (ret != 0) {
                MSC_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, index), err_msg, path);
                MS_SAFE_FREE(err_msg);
@@ -322,44 +322,38 @@ msc_validate_item(void **handle, const char *path)
        int res = MS_MEDIA_ERR_NONE;
        int ret;
        char *err_msg = NULL;
-       char mimetype[255] = {0};
        ms_storage_type_t storage_type;
 
-       ret = ms_get_mime(path, mimetype);
-       if (ret != MS_MEDIA_ERR_NONE) {
-               MSC_DBG_ERR("err : ms_get_mime [%d]", ret);
-               return ret;
-       }
        storage_type = ms_get_storage_type_by_full(path);
 
        for (lib_index = 0; lib_index < lib_num; lib_index++) {
-               if (!_msc_check_category(path, mimetype, lib_index)) {
+               if (!_msc_check_category(path, lib_index)) {
                        /*check exist in Media DB, If file is not exist, insert data in DB. */
                        ret = ((CHECK_ITEM_EXIST)func_array[lib_index][eEXIST])(handle[lib_index], path, storage_type, &err_msg); /*dlopen*/
                        if (ret != 0) {
                                MSC_DBG_ERR("not exist in %d. insert data", lib_index);
                                MS_SAFE_FREE(err_msg);
 
-                               ret = ((INSERT_ITEM)func_array[lib_index][eINSERT_BATCH])(handle[lib_index], path, storage_type, mimetype, &err_msg); /*dlopen*/
+                               ret = ((INSERT_ITEM)func_array[lib_index][eINSERT_BATCH])(handle[lib_index], path, storage_type, &err_msg); /*dlopen*/
                                if (ret != 0) {
                                        MSC_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, path);
-                                       MSC_DBG_ERR("[%s] %s", mimetype, path);
+                                       MSC_DBG_ERR("[%s]", path);
                                        MS_SAFE_FREE(err_msg);
                                        res = MS_MEDIA_ERR_DB_INSERT_FAIL;
                                }
                        } else {
                                /*if meta data of file exist, change valid field to "1" */
-                               ret = ((SET_ITEM_VALIDITY)func_array[lib_index][eSET_VALIDITY])(handle[lib_index], path, true, mimetype, true, &err_msg); /*dlopen*/
+                               ret = ((SET_ITEM_VALIDITY)func_array[lib_index][eSET_VALIDITY])(handle[lib_index], path, true, true, &err_msg); /*dlopen*/
                                if (ret != 0) {
                                        MSC_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, path);
-                                       MSC_DBG_ERR("[%s] %s", mimetype, path);
+                                       MSC_DBG_ERR("[%s]", path);;
                                        MS_SAFE_FREE(err_msg);
                                        res = MS_MEDIA_ERR_DB_UPDATE_FAIL;
                                }
                        }
                } else {
                        MSC_DBG_ERR("check category failed");
-                       MSC_DBG_ERR("[%s] %s", mimetype, path);
+                       MSC_DBG_ERR("[%s]", path);
                }
        }
 
@@ -396,30 +390,23 @@ msc_insert_item_batch(void **handle, const char *path)
        int lib_index;
        int res = MS_MEDIA_ERR_NONE;
        int ret;
-       char mimetype[255] = {0};
        char *err_msg = NULL;
        ms_storage_type_t storage_type;
 
-       ret = ms_get_mime(path, mimetype);
-       if (ret != MS_MEDIA_ERR_NONE) {
-               MSC_DBG_ERR("err : ms_get_mime [%d]", ret);
-               return ret;
-       }
-
        storage_type = ms_get_storage_type_by_full(path);
 
        for (lib_index = 0; lib_index < lib_num; lib_index++) {
-               if (!_msc_check_category(path, mimetype, lib_index)) {
-                       ret = ((INSERT_ITEM)func_array[lib_index][eINSERT_BATCH])(handle[lib_index], path, storage_type, mimetype, &err_msg); /*dlopen*/
+               if (!_msc_check_category(path, lib_index)) {
+                       ret = ((INSERT_ITEM)func_array[lib_index][eINSERT_BATCH])(handle[lib_index], path, storage_type, &err_msg); /*dlopen*/
                        if (ret != 0) {
                                MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
-                               MSC_DBG_ERR("[%s] %s", mimetype, path);
+                               MSC_DBG_ERR("[%s]", path);
                                MS_SAFE_FREE(err_msg);
                                res = MS_MEDIA_ERR_DB_INSERT_FAIL;
                        }
                } else {
                        MSC_DBG_ERR("check category failed");
-                       MSC_DBG_ERR("[%s] %s", mimetype, path);
+                       MSC_DBG_ERR("[%s]", path);
                }
        }
 
@@ -437,30 +424,23 @@ msc_insert_burst_item(void **handle, const char *path)
        int lib_index;
        int res = MS_MEDIA_ERR_NONE;
        int ret;
-       char mimetype[255] = {0};
        char *err_msg = NULL;
        ms_storage_type_t storage_type;
 
-       ret = ms_get_mime(path, mimetype);
-       if (ret != MS_MEDIA_ERR_NONE) {
-               MSC_DBG_ERR("err : ms_get_mime [%d]", ret);
-               return ret;
-       }
-
        storage_type = ms_get_storage_type_by_full(path);
 
        for (lib_index = 0; lib_index < lib_num; lib_index++) {
-               if (!_msc_check_category(path, mimetype, lib_index)) {
-                       ret = ((INSERT_BURST_ITEM)func_array[lib_index][eINSERT_BURST])(handle[lib_index], path, storage_type, mimetype, &err_msg); /*dlopen*/
+               if (!_msc_check_category(path, lib_index)) {
+                       ret = ((INSERT_BURST_ITEM)func_array[lib_index][eINSERT_BURST])(handle[lib_index], path, storage_type, &err_msg); /*dlopen*/
                        if (ret != 0) {
                                MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
-                               MSC_DBG_ERR("[%s] %s", mimetype, path);
+                               MSC_DBG_ERR("[%s]", path);
                                MS_SAFE_FREE(err_msg);
                                res = MS_MEDIA_ERR_DB_INSERT_FAIL;
                        }
                } else {
                        MSC_DBG_ERR("check category failed");
-                       MSC_DBG_ERR("[%s] %s", mimetype, path);
+                       MSC_DBG_ERR("[%s]", path);
                }
        }
 
index 3adf3b5..4636bba 100755 (executable)
@@ -158,18 +158,6 @@ static int _ms_check_stop_status(ms_storage_type_t storage_type)
        return ret;
 }
 
-static void _msc_insert_array(GArray *garray, ms_comm_msg_s *insert_data)
-{
-       MSC_DBG_INFO("path : %s", insert_data->msg);
-       MSC_DBG_INFO("scan_type : %d", insert_data->msg_type);
-
-       if (insert_data->pid == POWEROFF) {
-               g_array_prepend_val(garray, insert_data);
-       } else {
-               g_array_append_val(garray, insert_data);
-       }
-}
-
 void _msc_check_dir_path(char *dir_path)
 {
        /* need implementation */
@@ -344,42 +332,17 @@ static int _msc_db_update(void **handle, const ms_comm_msg_s * scan_data)
 gboolean msc_directory_scan_thread(void *data)
 {
        ms_comm_msg_s *scan_data = NULL;
-       ms_comm_msg_s *insert_data = NULL;
-       GArray *garray = NULL;
-       int length;
        int err;
        int ret;
        void **handle = NULL;
        ms_storage_type_t storage_type;
        int scan_type;
 
-       /*create array for processing overlay data*/
-       garray = g_array_new (FALSE, FALSE, sizeof (ms_comm_msg_s *));
-       if (garray == NULL) {
-               MSC_DBG_ERR("g_array_new error");
-               return false;
-       }
-
        while (1) {
-               length  = g_async_queue_length(scan_queue);
-
-               /*updating requests remain*/
-               if (garray->len != 0 && length == 0) {
-                       scan_data = g_array_index(garray, ms_comm_msg_s*, 0);
-                       g_array_remove_index (garray, 0);
-                       if (scan_data->pid == POWEROFF) {
-                               MSC_DBG_INFO("power off");
-                               goto _POWEROFF;
-                       }
-               } else if (length != 0) {
-                       insert_data = g_async_queue_pop(scan_queue);
-                       _msc_insert_array(garray, insert_data);
-                       continue;
-               } else if (garray->len == 0 && length == 0) {
-                       /*Threre is no request, Wait until pushung new request*/
-                       insert_data = g_async_queue_pop(scan_queue);
-                       _msc_insert_array(garray, insert_data);
-                       continue;
+               scan_data = g_async_queue_pop(scan_queue);
+               if (scan_data->pid == POWEROFF) {
+                       MSC_DBG_INFO("power off");
+                       goto _POWEROFF;
                }
 
                MSC_DBG_INFO("DIRECTORY SCAN START");
@@ -445,7 +408,6 @@ NEXT:
 
 _POWEROFF:
        MS_SAFE_FREE(scan_data);
-       if (garray) g_array_free (garray, TRUE);
        if (handle) msc_disconnect_db(&handle);
 
        return false;
@@ -455,43 +417,18 @@ _POWEROFF:
 gboolean msc_storage_scan_thread(void *data)
 {
        ms_comm_msg_s *scan_data = NULL;
-       ms_comm_msg_s *insert_data = NULL;
-       GArray *garray = NULL;
        bool res;
        int ret;
-       int length;
        int err;
        void **handle = NULL;
        ms_storage_type_t storage_type;
        int scan_type;
 
-       /*create array for processing overlay data*/
-       garray = g_array_new (FALSE, FALSE, sizeof (ms_comm_msg_s *));
-       if (garray == NULL) {
-               MSC_DBG_ERR("g_array_new error");
-               return false;
-       }
-
        while (1) {
-               length  = g_async_queue_length(storage_queue);
-
-               /*updating requests remain*/
-               if (garray->len != 0 && length == 0) {
-                       scan_data = g_array_index(garray, ms_comm_msg_s*, 0);
-                       g_array_remove_index (garray, 0);
-                       if (scan_data->pid == POWEROFF) {
-                               MSC_DBG_INFO("power off");
-                               goto _POWEROFF;
-                       }
-               } else if (length != 0) {
-                       insert_data = g_async_queue_pop(storage_queue);
-                       _msc_insert_array(garray, insert_data);
-                       continue;
-               } else if (garray->len == 0 && length == 0) {
-                       /*Threre is no request, Wait until pushing new request*/
-                       insert_data = g_async_queue_pop(storage_queue);
-                       _msc_insert_array(garray, insert_data);
-                       continue;
+               scan_data = g_async_queue_pop(storage_queue);
+               if (scan_data->pid == POWEROFF) {
+                       MSC_DBG_INFO("power off");
+                       goto _POWEROFF;
                }
 
                MSC_DBG_INFO("STORAGE SCAN START");
@@ -589,7 +526,6 @@ NEXT:
 
 _POWEROFF:
        MS_SAFE_FREE(scan_data);
-       if (garray) g_array_free (garray, TRUE);
        if (handle) msc_disconnect_db(&handle);
 
        return false;
index 8a2762d..4a36851 100755 (executable)
@@ -31,7 +31,6 @@
 #include <dirent.h>
 #include <vconf.h>
 #include <heynoti.h>
-#include <errno.h>
 
 #include "media-common-utils.h"
 #include "media-common-drm.h"
@@ -103,7 +102,7 @@ bool check_process(void)
                                }
                        }
                } else {
-                       MSC_DBG_ERR("media-server: Looking for process of name: [%s]. Cannot find. Reason: %s", APP_NAME, strerror(errno));
+                       MSC_DBG_ERR("Can't read file [%s]", path);
                }
        }
 
@@ -142,6 +141,13 @@ static void _power_off_cb(void* data)
                g_async_queue_push(reg_queue, GINT_TO_POINTER(reg_data));
        }
 
+       if (storage_queue) {
+               /*notify to register thread*/
+               MS_MALLOC(reg_data, sizeof(ms_comm_msg_s));
+               reg_data->pid = POWEROFF;
+               g_async_queue_push(storage_queue, GINT_TO_POINTER(reg_data));
+       }
+
        if (g_main_loop_is_running(scanner_mainloop)) g_main_loop_quit(scanner_mainloop);
 }
 
@@ -149,9 +155,10 @@ void
 _msc_mmc_vconf_cb(void *data)
 {
        int status = 0;
+/*
        ms_comm_msg_s *scan_msg;
        ms_dir_scan_type_t scan_type = MS_SCAN_PART;
-
+*/
        if (!ms_config_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &status)) {
                MSC_DBG_ERR("Get VCONFKEY_SYSMAN_MMC_STATUS failed.");
        }
index 87b48e0..41f45e4 100755 (executable)
@@ -99,7 +99,7 @@ bool check_process()
                                }
                        }
                } else {
-                       MS_DBG_ERR("media-server: Looking for process of name: [%s]. Cannot find. Reason: %s", APP_NAME, strerror(errno));
+                       MS_DBG_ERR("Can't read file [%s]", path);
                }
        }
 
@@ -178,24 +178,24 @@ void _ms_signal_handler(int n)
 
        pid = waitpid(-1, &stat, WNOHANG);
        /* check pid of child process of thumbnail thread */
-       MS_DBG("[PID %d] signal ID %d", pid, n);
+       MS_DBG_ERR("[PID %d] signal ID %d", pid, n);
 
        if (pid == thumb_pid) {
-               MS_DBG("Thumbnail server is dead");
+               MS_DBG_ERR("Thumbnail server is dead");
                ms_thumb_reset_server_status();
        } else if (pid == scanner_pid) {
-               MS_DBG("Scanner is dead");
+               MS_DBG_ERR("Scanner is dead");
                ms_reset_scanner_status();
        } else if (pid == -1) {
-               MS_DBG("%s", strerror(errno));
+               MS_DBG_ERR("%s", strerror(errno));
        }
 
        if (WIFEXITED(stat)) {
-               MS_DBG("normal termination , exit status : %d", WEXITSTATUS(stat));
+               MS_DBG_ERR("normal termination , exit status : %d", WEXITSTATUS(stat));
        } else if (WIFSIGNALED(stat)) {
-               MS_DBG("abnormal termination , signal number : %d", WTERMSIG(stat));
+               MS_DBG_ERR("abnormal termination , signal number : %d", WTERMSIG(stat));
        } else if (WIFSTOPPED(stat)) {
-               MS_DBG("child process is stoped, signal number : %d", WSTOPSIG(stat));
+               MS_DBG_ERR("child process is stoped, signal number : %d", WSTOPSIG(stat));
        }
 
        return;
index d7ad49e..c889d9e 100755 (executable)
@@ -494,10 +494,11 @@ gboolean ms_read_db_tcp_socket(GIOChannel *src, GIOCondition condition, gpointer
                        }
                }
 
-               MS_DBG("Received [%d](%d) [%s]", recv_msg.msg_type, recv_msg.msg_size, recv_msg.msg);
+//             MS_DBG("Received [%d](%d) [%s]", recv_msg.msg_type, recv_msg.msg_size, recv_msg.msg);
 
                if((recv_msg.msg_size <= 0) ||(recv_msg.msg_size > MS_FILE_PATH_LEN_MAX)  || (!MS_STRING_VALID(recv_msg.msg))) {
                        MS_DBG_ERR("invalid query. size[%d]", recv_msg.msg_size);
+                       MS_DBG_ERR("Received [%d](%d) [%s]", recv_msg.msg_type, recv_msg.msg_size, recv_msg.msg);
                        close(client_sock);
                        return TRUE;
                }
index 02b85ab..35bdef4 100755 (executable)
@@ -180,8 +180,7 @@ bool _ms_thumb_check_process()
                                break;
                        }
                } else {
-                       MS_DBG_ERR("media-server: Looking for process of name: [%s]. Cannot find. Reason: %s", 
-                               THUMB_SERVER_NAME, strerror(errno));
+                       MS_DBG_ERR("Can't read file [%s]", path);
                }
        }
 
@@ -260,6 +259,11 @@ int _media_thumb_get_error()
 {
        if (errno == EWOULDBLOCK) {
                MS_DBG_ERR("Timeout. Can't try any more");
+               if (!_ms_thumb_check_process()) {
+                       MS_DBG_ERR("Thumbnail server is not running!. Reset info for thumb server to execute");
+                       ms_thumb_reset_server_status();
+               }
+
                return MS_MEDIA_ERR_SOCKET_RECEIVE_TIMEOUT;
        } else {
                MS_DBG_ERR("recvfrom failed : %s", strerror(errno));