Modify thumbnail creation and cancellation logic 04/47604/1 tizen_3.0.m1_mobile tizen_3.0.m1_tv accepted/tizen/mobile/20150907.084922 accepted/tizen/tv/20150907.084954 accepted/tizen/wearable/20150907.084937 submit/tizen/20150907.055530 submit/tizen_common/20151015.190624 submit/tizen_common/20151019.135620 submit/tizen_common/20151023.083358 submit/tizen_common/20151026.085049 tizen_3.0.m1_mobile_release tizen_3.0.m1_tv_release
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 7 Sep 2015 04:10:55 +0000 (13:10 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Mon, 7 Sep 2015 04:10:55 +0000 (13:10 +0900)
Change-Id: I4bab6e37f9d943c719325f971ae9d3499a77f93f
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media-thumbnail.h
server/include/thumb-server-internal.h
server/thumb-server-internal.c
src/codec/img-codec-parser.c
src/include/ipc/media-thumb-ipc.h
src/ipc/media-thumb-ipc.c
src/media-thumb-internal.c
src/media-thumbnail.c
test/test-thumb.c

index 7bda30c..0d05d55 100755 (executable)
@@ -45,11 +45,11 @@ int thumbnail_request_extract_all_thumbs(uid_t uid);
 
 int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_path, int max_length, int *origin_width, int *origin_height, uid_t uid);
 
-int thumbnail_request_cancel_media(const char *origin_path, uid_t uid);
+int thumbnail_request_cancel_media(const char *origin_path);
 
-int thumbnail_request_cancel_raw_data(int request_id, uid_t uid);
+int thumbnail_request_cancel_raw_data(int request_id);
 
-int thumbnail_request_cancel_all(bool is_raw_data, uid_t uid);
+int thumbnail_request_cancel_all(bool is_raw_data);
 
 #ifdef __cplusplus
 }
index 0e16c74..7869fe3 100755 (executable)
@@ -41,7 +41,7 @@ typedef enum {
 } _server_mode_e;
 
 gboolean _thumb_daemon_start_jobs(gpointer data);
-void _thumb_daemon_finish_jobs();
+void _thumb_daemon_finish_jobs(void);
 void _thumb_daemon_mmc_eject_vconf_cb(void *data);
 void _thumb_daemon_vconf_cb(void *data);
 gboolean _thumb_server_prepare_socket(int *sock_fd);
index 6a94fe2..5facdee 100755 (executable)
@@ -50,8 +50,10 @@ static __thread int g_cur_idx = 0;
 
 GMainLoop *g_thumb_server_mainloop; // defined in thumb-server.c as extern
 
-gboolean _thumb_server_send_msg_to_agent(int msg_type);
-void _thumb_daemon_stop_job();
+static gboolean __thumb_server_send_msg_to_agent(int msg_type);
+static void __thumb_daemon_stop_job(void);
+static int __thumb_daemon_all_extract(uid_t uid);
+int _thumb_daemon_process_queue_jobs(gpointer data);
 static gboolean _thumb_server_send_deny_message(int sockfd);
 
 gboolean _thumb_daemon_start_jobs(gpointer data)
@@ -60,7 +62,7 @@ gboolean _thumb_daemon_start_jobs(gpointer data)
        /* Initialize ecore-evas to use evas library */
        ecore_evas_init();
 
-       _thumb_server_send_msg_to_agent(MS_MSG_THUMB_SERVER_READY);
+       __thumb_server_send_msg_to_agent(MS_MSG_THUMB_SERVER_READY);
 
        return FALSE;
 }
@@ -110,7 +112,7 @@ void _thumb_daemon_mmc_eject_vconf_cb(void *data)
                if (status == VCONFKEY_SYSMAN_MMC_REMOVED || status == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
                        thumb_warn("SD card is ejected or not mounted. So media-thumbnail-server stops jobs to extract all thumbnails");
 
-                       _thumb_daemon_stop_job();
+                       __thumb_daemon_stop_job();
                }
        } else if (err == -1) {
                thumb_err("vconf_get_int failed : %d", err);
@@ -133,7 +135,7 @@ void _thumb_daemon_vconf_cb(void *data)
                if (status == VCONFKEY_SYSMAN_MMC_FORMAT_COMPLETED) {
                        thumb_warn("SD card format is completed. So media-thumbnail-server stops jobs to extract all thumbnails");
 
-                       _thumb_daemon_stop_job();
+                       __thumb_daemon_stop_job();
                } else {
                        thumb_dbg("not completed");
                }
@@ -146,7 +148,7 @@ void _thumb_daemon_vconf_cb(void *data)
        return;
 }
 
-void _thumb_daemon_stop_job()
+static void __thumb_daemon_stop_job()
 {
        int i = 0;
        char *path = NULL;
@@ -201,7 +203,7 @@ static int __thumb_daemon_process_job_raw(thumbMsg *req_msg, thumbMsg *res_msg)
        return err;
 }
 
-int _thumb_daemon_all_extract(uid_t uid)
+static int __thumb_daemon_all_extract(uid_t uid)
 {
        int err = MS_MEDIA_ERR_NONE;
        char query_string[MAX_PATH_SIZE + 1] = { 0, };
@@ -320,7 +322,7 @@ int _thumb_daemon_process_queue_jobs(gpointer data)
                SAFE_FREE(arr_uid);
                //_media_thumb_db_disconnect();
 
-               _thumb_server_send_msg_to_agent(MS_MSG_THUMB_EXTRACT_ALL_DONE); // MS_MSG_THUMB_EXTRACT_ALL_DONE
+               __thumb_server_send_msg_to_agent(MS_MSG_THUMB_EXTRACT_ALL_DONE); // MS_MSG_THUMB_EXTRACT_ALL_DONE
 
                return FALSE;
        }
@@ -334,7 +336,6 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
 {
        struct sockaddr_un client_addr;
        unsigned int client_addr_len;
-
        thumbMsg recv_msg;
        thumbMsg res_msg;
        ms_peer_credentials credentials;
@@ -388,7 +389,7 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
 
        if (recv_msg.msg_type == THUMB_REQUEST_ALL_MEDIA) {
                thumb_dbg("All thumbnails are being extracted now");
-               _thumb_daemon_all_extract(recv_msg.uid);
+               __thumb_daemon_all_extract(recv_msg.uid);
                g_idle_add(_thumb_daemon_process_queue_jobs, NULL);
        } else if(recv_msg.msg_type == THUMB_REQUEST_RAW_DATA) {
                __thumb_daemon_process_job_raw(&recv_msg, &res_msg);
@@ -445,7 +446,7 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
        return TRUE;
 }
 
-gboolean _thumb_server_send_msg_to_agent(int msg_type)
+static gboolean __thumb_server_send_msg_to_agent(int msg_type)
 {
        int sock;
        ms_sock_info_s sock_info;
index 2d8d348..8cc94d5 100755 (executable)
@@ -275,10 +275,9 @@ static int _ImgGetImageInfo(HFile hFile, unsigned long fileSize, char *fileExt,
                                (EncodedDataBuffer[21] << 24);
                }
                if (pHeight) {
-                       *pHeight =
-                               EncodedDataBuffer[22] | (EncodedDataBuffer[23] << 8)
-                               | (EncodedDataBuffer[24] << 16) |
-                               (EncodedDataBuffer[25] << 24);
+                       // add the reference function abs(). may have negative height values in bmp header.
+                       *pHeight = abs(EncodedDataBuffer[22] | (EncodedDataBuffer[23] << 8) | 
+                                                 (EncodedDataBuffer[24] << 16) | (EncodedDataBuffer[25] << 24));
                }
 
                thumb_dbg("IMG_CODEC_BMP");
index 5eacf12..aa5db4b 100755 (executable)
@@ -85,4 +85,6 @@ int _media_thumb_request_raw_data_async(int msg_type,
                                        thumbRawUserData *userData,
                                        uid_t uid);
 
+int _media_thumb_request_cancel_all(bool isRaw);
+
 #endif /*_MEDIA_THUMB_IPC_H_*/
index b10a5be..bf9e568 100755 (executable)
 #include <grp.h>
 #include <pwd.h>
 
-#define GLOBAL_USER    0 //#define     tzplatform_getenv(TZ_GLOBAL) //TODO
 #define THUMB_SOCK_BLOCK_SIZE 512
 
-static __thread GQueue *g_request_queue = NULL;
+static GQueue *g_request_queue = NULL;
+static GQueue *g_manage_queue = NULL;
+static GQueue *g_request_raw_queue = NULL;
+static GQueue *g_manage_raw_queue = NULL;
+
+
 typedef struct {
        GIOChannel *channel;
-       char *path;
+       int msg_type;
+       bool isCanceled;
        int source_id;
+       uid_t uid;
+       char *path;
        thumbUserData *userData;
 } thumbReq;
 
 typedef struct {
        GIOChannel *channel;
+       int msg_type;
+       bool isCanceled;
        int request_id;
        int source_id;
+       int width;
+       int height;
+       uid_t uid;
+       char *path;
        thumbRawUserData *userData;
 } thumbRawReq;
 
+int _media_thumb_send_request();
+int _media_thumb_raw_data_send_request();
 
 
 int _media_thumb_get_error()
@@ -57,7 +72,7 @@ int _media_thumb_get_error()
                thumb_err("Timeout. Can't try any more");
                return MS_MEDIA_ERR_SOCKET_RECEIVE_TIMEOUT;
        } else {
-               thumb_err("recvfrom failed : %s", strerror(errno));
+               thumb_stderror("recvfrom failed");
                return MS_MEDIA_ERR_SOCKET_RECEIVE;
        }
 }
@@ -66,7 +81,6 @@ int __media_thumb_pop_req_queue(const char *path, bool shutdown_channel)
 {
        int req_len = 0, i;
 
-       if (g_request_queue == NULL) return MS_MEDIA_ERR_INVALID_PARAMETER;
        req_len = g_queue_get_length(g_request_queue);
 
        if (req_len <= 0) {
@@ -107,12 +121,66 @@ int __media_thumb_pop_req_queue(const char *path, bool shutdown_channel)
        return MS_MEDIA_ERR_NONE;
 }
 
+int __media_thumb_check_req_queue_for_cancel(const char *path)
+{
+       int req_len = 0;
+
+       req_len = g_queue_get_length(g_request_queue);
+
+       if (req_len <= 0) {
+//             thumb_dbg("There is no request in the queue");
+       } else {
+               thumbReq *req = NULL;
+               req = (thumbReq *)g_queue_peek_head(g_request_queue);
+
+               if (req != NULL && strncmp(path, req->path, strlen(path)) == 0) {
+                       req->isCanceled = true;
+                       return MS_MEDIA_ERR_NONE;
+               }
+       }
+
+       return MS_MEDIA_ERR_INTERNAL;
+}
+
+int __media_thumb_pop_manage_queue(const char *path)
+{
+       int req_len = 0, i;
+       bool flag = false;
+
+       req_len = g_queue_get_length(g_manage_queue);
+
+       if (req_len < 0) {
+//             thumb_dbg("There is no request in the queue");
+       } else {
+               for (i = 0; i < req_len; i++) {
+                       thumbReq *req = NULL;
+                       req = (thumbReq *)g_queue_peek_nth(g_manage_queue, i);
+                       if (req == NULL) continue;
+
+                       if (strncmp(path, req->path, strlen(path)) == 0) {
+                               g_queue_pop_nth(g_manage_queue, i);
+
+                               SAFE_FREE(req->path);
+                               SAFE_FREE(req->userData);
+                               SAFE_FREE(req);
+                               flag = true;
+                               break;
+                       }
+               }
+               if(!flag) {
+                       return __media_thumb_check_req_queue_for_cancel(path);
+               }
+       }
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+
 int __media_thumb_pop_raw_data_req_queue(int request_id, bool shutdown_channel)
 {
        int req_len = 0, i;
 
-       if (g_request_queue == NULL) return MS_MEDIA_ERR_INVALID_PARAMETER;
-       req_len = g_queue_get_length(g_request_queue);
+       req_len = g_queue_get_length(g_request_raw_queue);
 
        if (req_len <= 0) {
 //             thumb_dbg("There is no request in the queue");
@@ -120,7 +188,7 @@ int __media_thumb_pop_raw_data_req_queue(int request_id, bool shutdown_channel)
 
                for (i = 0; i < req_len; i++) {
                        thumbRawReq *req = NULL;
-                       req = (thumbRawReq *)g_queue_peek_nth(g_request_queue, i);
+                       req = (thumbRawReq *)g_queue_peek_nth(g_request_raw_queue, i);
                        if (req == NULL) continue;
 
                        if (request_id == req->request_id) {
@@ -135,7 +203,7 @@ int __media_thumb_pop_raw_data_req_queue(int request_id, bool shutdown_channel)
                                        g_io_channel_shutdown(req->channel, TRUE, NULL);
                                        g_io_channel_unref(req->channel);
                                }
-                               g_queue_pop_nth(g_request_queue, i);
+                               g_queue_pop_nth(g_request_raw_queue, i);
 
                                SAFE_FREE(req->userData);
                                SAFE_FREE(req);
@@ -151,6 +219,60 @@ int __media_thumb_pop_raw_data_req_queue(int request_id, bool shutdown_channel)
        return MS_MEDIA_ERR_NONE;
 }
 
+int __media_thumb_check_raw_data_req_queue_for_cancel(int request_id)
+{
+       int req_len = 0;
+
+       req_len = g_queue_get_length(g_request_raw_queue);
+
+       if (req_len <= 0) {
+//             thumb_dbg("There is no request in the queue");
+       } else {
+               thumbRawReq *req = NULL;
+               req = (thumbRawReq *)g_queue_peek_head(g_request_raw_queue);
+
+               if (req != NULL && request_id == req->request_id) {
+                       req->isCanceled = true;
+                       return MS_MEDIA_ERR_NONE;
+               }
+       }
+
+       return MS_MEDIA_ERR_INTERNAL;
+}
+
+int __media_thumb_pop_raw_data_manage_queue(int request_id)
+{
+       int req_len = 0, i;
+       int flag = false;
+
+       req_len = g_queue_get_length(g_manage_raw_queue);
+
+       if (req_len < 0) {
+//             thumb_dbg("There is no request in the queue");
+       } else {
+
+               for (i = 0; i < req_len; i++) {
+                       thumbRawReq *req = NULL;
+                       req = (thumbRawReq *)g_queue_peek_nth(g_manage_raw_queue, i);
+                       if (req == NULL) continue;
+
+                       if (request_id == req->request_id) {
+                               g_queue_pop_nth(g_manage_raw_queue, i);
+
+                               SAFE_FREE(req->userData);
+                               SAFE_FREE(req);
+                               flag = true;
+                               break;
+                       }
+               }
+               if(!flag) {
+                       return __media_thumb_check_raw_data_req_queue_for_cancel(request_id);
+               }
+       }
+
+       return MS_MEDIA_ERR_NONE;
+}
+
 int __media_thumb_check_req_queue(const char *path)
 {
        int req_len = 0, i;
@@ -181,6 +303,36 @@ int __media_thumb_check_req_queue(const char *path)
        return MS_MEDIA_ERR_NONE;
 }
 
+bool __media_thumb_check_cancel(void)
+{
+       thumbReq *req = NULL;
+       req = (thumbReq *)g_queue_peek_head(g_request_queue);
+
+       if (req == NULL) {
+               return false;
+       } else {
+               if(req->isCanceled)
+                       return false;
+               else
+                       return true;
+       }
+}
+
+bool __media_thumb_check_cancel_for_raw(void)
+{
+       thumbRawReq *req = NULL;
+       req = (thumbRawReq *)g_queue_peek_head(g_request_raw_queue);
+
+       if (req == NULL) {
+               return false;
+       } else {
+               if(req->isCanceled)
+                       return false;
+               else
+                       return true;
+       }
+}
+
 int
 _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
 {
@@ -191,8 +343,8 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
        unsigned char *buf = NULL;
        unsigned char *block_buf = NULL;
 
-       buf = (unsigned char*)malloc(header_size * sizeof(unsigned char));
-       block_buf = (unsigned char*)malloc(THUMB_SOCK_BLOCK_SIZE * sizeof(unsigned char));
+       THUMB_MALLOC(buf, header_size);
+       THUMB_MALLOC(block_buf, THUMB_SOCK_BLOCK_SIZE);
        if (buf == NULL || block_buf == NULL) {
                thumb_err("memory allocation failed");
                SAFE_FREE(buf);
@@ -203,6 +355,7 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
        if ((recv_msg_len = recv(sock, buf, header_size, 0)) <= 0) {
                thumb_stderror("recv failed");
                SAFE_FREE(buf);
+               SAFE_FREE(block_buf);
                return _media_thumb_get_error();
        }
 
@@ -210,17 +363,25 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
        //thumb_dbg("origin_path_size : %d, dest_path_size : %d, thumb_size : %d", msg->origin_path_size, msg->dest_path_size, msg->thumb_size);
 
        SAFE_FREE(buf);
+       if(msg->origin_path_size < 0  ||msg->dest_path_size < 0 || msg->thumb_size < 0) {
+               thumb_err("recv data is wrong");
+               SAFE_FREE(block_buf);
+               return MS_MEDIA_ERR_SOCKET_RECEIVE;
+       }
 
        remain_size = msg->origin_path_size + msg->dest_path_size + msg->thumb_size;
-       buf = malloc(remain_size * sizeof(unsigned char));
-       memset(buf, 0, remain_size * sizeof(unsigned char));
+       THUMB_MALLOC(buf, remain_size);
+       if(buf == NULL) {
+               SAFE_FREE(block_buf);
+               return MS_MEDIA_ERR_OUT_OF_MEMORY;
+       }
 
        while(remain_size > 0) {
                if(remain_size < THUMB_SOCK_BLOCK_SIZE) {
                        block_size = remain_size;
                }
                if ((recv_msg_len = recv(sock, block_buf, block_size, 0)) < 0) {
-                       thumb_err("recv failed : %s", strerror(errno));
+                       thumb_stderror("recv failed");
                        SAFE_FREE(buf);
                        SAFE_FREE(block_buf);
                        return _media_thumb_get_error();
@@ -234,9 +395,17 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
        strncpy(msg->dst_path, (char *)buf + msg->origin_path_size, msg->dest_path_size);
 
        SAFE_FREE(msg->thumb_data);
-       msg->thumb_data = malloc(msg->thumb_size);
-       memset(msg->thumb_data, 0, msg->thumb_size);
-       memcpy(msg->thumb_data, buf + msg->origin_path_size + msg->dest_path_size, msg->thumb_size);
+       if(msg->thumb_size > 0) {
+               THUMB_MALLOC(msg->thumb_data, msg->thumb_size);
+               if(msg->thumb_data != NULL) {
+                       memcpy(msg->thumb_data, buf + msg->origin_path_size + msg->dest_path_size, msg->thumb_size);
+               } else {
+                       SAFE_FREE(buf);
+                       SAFE_FREE(block_buf);
+
+                       return MS_MEDIA_ERR_OUT_OF_MEMORY;
+               }
+       }
 
        SAFE_FREE(buf);
        SAFE_FREE(block_buf);
@@ -251,7 +420,11 @@ _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct socka
        unsigned int from_addr_size = sizeof(struct sockaddr_un);
        unsigned char *buf = NULL;
 
-       buf = (unsigned char*)malloc(sizeof(thumbMsg));
+       THUMB_MALLOC(buf, sizeof(thumbMsg));
+       if (buf == NULL) {
+               thumb_err("memory allocation failed");
+               return MS_MEDIA_ERR_OUT_OF_MEMORY;
+       }
 
        if ((recv_msg_len = recvfrom(sock, buf, sizeof(thumbMsg), 0, (struct sockaddr *)from_addr, &from_addr_size)) < 0) {
                thumb_stderror("recvform failed");
@@ -304,8 +477,7 @@ _media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size)
        //thumb_dbg("Basic Size : %d, org_path : %s[%d], dst_path : %s[%d], thumb_data_len : %d", header_size, req_msg->org_path, org_path_len, req_msg->dst_path, dst_path_len, thumb_data_len);
 
        size = header_size + org_path_len + dst_path_len + thumb_data_len;
-       *buf = malloc(size);
-
+       THUMB_MALLOC(*buf, size);
        if (*buf == NULL) {
                *buf_size = 0;
                return 0;
@@ -332,7 +504,7 @@ _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, in
        int pid;
        sock_info.port = MS_THUMB_CREATOR_PORT;
 
-       err = ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock_info);
+       err = ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock_info);
        if (err != MS_MEDIA_ERR_NONE) {
                thumb_err("ms_ipc_create_client_socket failed");
                return err;
@@ -399,37 +571,38 @@ _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, in
 
        SAFE_FREE(buf);
 
-       if(msg_type != THUMB_REQUEST_CANCEL_ALL_RAW_DATA && msg_type != THUMB_REQUEST_CANCEL_ALL) {             //No response..
-               if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) {
-                       thumb_err("_media_thumb_recv_msg failed ");
-                       ms_ipc_delete_client_socket(&sock_info);
-                       return err;
-               }
-
-               recv_str_len = strlen(recv_msg.org_path);
-               thumb_dbg_slog("recv %s(%d) from thumb daemon is successful", recv_msg.org_path, recv_str_len);
-
+       if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) {
+               thumb_err("_media_thumb_recv_msg failed ");
                ms_ipc_delete_client_socket(&sock_info);
+               return err;
+       }
 
-               if (recv_str_len > max_length) {
-                       thumb_err("user buffer is too small. Output's length is %d", recv_str_len);
-                       return MS_MEDIA_ERR_INVALID_PARAMETER;
-               }
+       recv_str_len = strlen(recv_msg.org_path);
+       thumb_dbg_slog("recv %s(%d) from thumb daemon is successful", recv_msg.org_path, recv_str_len);
 
-               if (recv_msg.status == THUMB_FAIL) {
-                       thumb_err("Failed to make thumbnail");
-                       return MS_MEDIA_ERR_INVALID_PARAMETER;
-               }
+       ms_ipc_delete_client_socket(&sock_info);
 
-               if (msg_type != THUMB_REQUEST_SAVE_FILE) {
-                       strncpy(thumb_path, recv_msg.dst_path, max_length);
-               }
+       if (recv_str_len > max_length) {
+               thumb_err("user buffer is too small. Output's length is %d", recv_str_len);
+               SAFE_FREE(recv_msg.thumb_data);
+               return MS_MEDIA_ERR_INVALID_PARAMETER;
+       }
+
+       if (recv_msg.status == THUMB_FAIL) {
+               thumb_err("Failed to make thumbnail");
+               SAFE_FREE(recv_msg.thumb_data);
+               return MS_MEDIA_ERR_INVALID_PARAMETER;
+       }
 
-               thumb_info->origin_width = recv_msg.origin_width;
-               thumb_info->origin_height = recv_msg.origin_height;
-       }else {
-               thumb_dbg("No response msg_type:[%d]", msg_type);
+       if (msg_type != THUMB_REQUEST_SAVE_FILE) {
+               strncpy(thumb_path, recv_msg.dst_path, max_length);
        }
+
+       thumb_info->origin_width = recv_msg.origin_width;
+       thumb_info->origin_height = recv_msg.origin_height;
+
+       SAFE_FREE(recv_msg.thumb_data);
+
        return MS_MEDIA_ERR_NONE;
 }
 
@@ -438,6 +611,7 @@ gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpoi
        thumbMsg recv_msg;
        int header_size = 0;
        int sock = 0;
+       int len = -1;
        int err = MS_MEDIA_ERR_NONE;
 
        memset((void *)&recv_msg, 0, sizeof(thumbMsg));
@@ -467,15 +641,32 @@ gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpoi
                err = MS_MEDIA_ERR_INTERNAL;
        }
 
-       if (data) {
-               thumbUserData* cb = (thumbUserData*)data;
-               if (cb->func != NULL)
-                       cb->func(err, recv_msg.dst_path, cb->user_data);
+       if(__media_thumb_check_cancel()) {
+               if (data) {
+                       thumbUserData* cb = (thumbUserData*)data;
+                       if (cb->func != NULL)
+                               cb->func(err, recv_msg.dst_path, cb->user_data);
+               }
        }
 
        __media_thumb_pop_req_queue(recv_msg.org_path, FALSE);
 
        thumb_dbg("Done");
+
+       SAFE_FREE(recv_msg.thumb_data);
+
+       /* Check manage queue */
+       if(g_manage_queue) {
+               len = g_queue_get_length(g_manage_queue);
+
+               if(len > 0) {
+                       _media_thumb_send_request();
+               } else {
+                       g_queue_free(g_manage_queue);
+                       g_manage_queue = NULL;
+               }
+       }
+
        return FALSE;
 }
 
@@ -484,6 +675,7 @@ gboolean _media_thumb_raw_data_write_socket(GIOChannel *src, GIOCondition condit
        thumbMsg recv_msg;
        int header_size = 0;
        int sock = 0;
+       int len = -1;
        int err = MS_MEDIA_ERR_NONE;
 
        memset((void *)&recv_msg, 0, sizeof(thumbMsg));
@@ -512,10 +704,12 @@ gboolean _media_thumb_raw_data_write_socket(GIOChannel *src, GIOCondition condit
                err = MS_MEDIA_ERR_INTERNAL;
        }
 
-       if (data) {
-               thumbRawUserData* cb = (thumbRawUserData*)data;
-               if (cb->func != NULL)
-                       cb->func(err, recv_msg.request_id, recv_msg.org_path, recv_msg.thumb_width, recv_msg.thumb_height, recv_msg.thumb_data, recv_msg.thumb_size, cb->user_data);
+       if(__media_thumb_check_cancel_for_raw()) {
+               if (data) {
+                       thumbRawUserData* cb = (thumbRawUserData*)data;
+                       if (cb->func != NULL)
+                               cb->func(err, recv_msg.request_id, recv_msg.org_path, recv_msg.thumb_width, recv_msg.thumb_height, recv_msg.thumb_data, recv_msg.thumb_size, cb->user_data);
+               }
        }
 
        __media_thumb_pop_raw_data_req_queue(recv_msg.request_id, FALSE);
@@ -524,22 +718,30 @@ gboolean _media_thumb_raw_data_write_socket(GIOChannel *src, GIOCondition condit
 
        SAFE_FREE(recv_msg.thumb_data);
 
+       /* Check manage queue */
+       if(g_manage_raw_queue) {
+               len = g_queue_get_length(g_manage_raw_queue);
+
+               if(len > 0) {
+                       _media_thumb_raw_data_send_request();
+               } else {
+                       g_queue_free(g_manage_raw_queue);
+                       g_manage_raw_queue = NULL;
+               }
+       }
+
        return FALSE;
 }
 
-int _media_thumb_request_async(int msg_type, const char *origin_path, thumbUserData *userData, uid_t uid)
-{
+int _media_thumb_send_request() {
        int err = MS_MEDIA_ERR_NONE;
        int sock = -1;
        struct sockaddr_un serv_addr;
        ms_sock_info_s sock_info;
+       thumbReq *req_manager = NULL;
        int pid;
        sock_info.port = MS_THUMB_CREATOR_PORT;
 
-       if ((msg_type == THUMB_REQUEST_DB_INSERT) && (__media_thumb_check_req_queue(origin_path) < 0)) {
-               return MS_MEDIA_ERR_THUMB_DUPLICATED_REQUEST;
-       }
-
        err = ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock_info);
        if(err != MS_MEDIA_ERR_NONE)
        {
@@ -563,26 +765,22 @@ int _media_thumb_request_async(int msg_type, const char *origin_path, thumbUserD
                g_io_channel_unref(channel);
                return MS_MEDIA_ERR_SOCKET_CONN;
        }
-
-       if (msg_type != THUMB_REQUEST_CANCEL_MEDIA) {
-               /* Create new channel to watch udp socket */
-               GSource *source = NULL;
-               source = g_io_create_watch(channel, G_IO_IN);
-
-               /* Set callback to be called when socket is readable */
-               g_source_set_callback(source, (GSourceFunc)_media_thumb_write_socket, userData, NULL);
-               source_id = g_source_attach(source, g_main_context_get_thread_default());
-       }
+       req_manager = (thumbReq *)g_queue_pop_head(g_manage_queue);
+       GSource *source = NULL;
+       source = g_io_create_watch(channel, G_IO_IN);
+       g_source_set_callback(source, (GSourceFunc)_media_thumb_write_socket, req_manager->userData, NULL);
+       source_id = g_source_attach(source, g_main_context_get_thread_default());
 
        thumbMsg req_msg;
+
        memset((void *)&req_msg, 0, sizeof(thumbMsg));
 
        pid = getpid();
        req_msg.pid = pid;
-       req_msg.msg_type = msg_type;
-       req_msg.uid = uid;
-
-       strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
+       req_msg.msg_type = req_manager->msg_type;
+       req_msg.request_id = 0;
+       req_msg.uid = req_manager->uid;
+       strncpy(req_msg.org_path, req_manager->path, sizeof(req_msg.org_path));
        req_msg.org_path[strlen(req_msg.org_path)] = '\0';
        req_msg.dst_path[0] = '\0';
        req_msg.origin_path_size = strlen(req_msg.org_path) + 1;
@@ -614,38 +812,36 @@ int _media_thumb_request_async(int msg_type, const char *origin_path, thumbUserD
        SAFE_FREE(buf);
        thumb_dbg("Sending msg to thumbnail daemon is successful");
 
-       if (msg_type == THUMB_REQUEST_CANCEL_MEDIA) {
-               g_io_channel_shutdown(channel, TRUE, NULL);
-               __media_thumb_pop_req_queue(origin_path, TRUE);
-       } else if (msg_type == THUMB_REQUEST_DB_INSERT) {
+
+       if (req_manager->msg_type == THUMB_REQUEST_DB_INSERT) {
                if (g_request_queue == NULL) {
-                       g_request_queue = g_queue_new();
+                       g_request_queue = g_queue_new();
                }
 
                thumbReq *thumb_req = NULL;
-               thumb_req = calloc(1, sizeof(thumbReq));
+               THUMB_MALLOC(thumb_req, sizeof(thumbReq));
                if (thumb_req == NULL) {
                        thumb_err("Failed to create request element");
                        return MS_MEDIA_ERR_INVALID_PARAMETER;
                }
 
                thumb_req->channel = channel;
-               thumb_req->path = strdup(origin_path);
+               thumb_req->path = strdup(req_manager->path);
                thumb_req->source_id = source_id;
-               thumb_req->userData = userData;
+               thumb_req->userData = req_manager->userData;
 
                g_queue_push_tail(g_request_queue, (gpointer)thumb_req);
        }
 
-       return MS_MEDIA_ERR_NONE;
+       return err;
 }
 
-int _media_thumb_request_raw_data_async(int msg_type, int request_id, const char *origin_path, int width, int height, thumbRawUserData *userData, uid_t uid)
-{
+int _media_thumb_raw_data_send_request() {
        int err = MS_MEDIA_ERR_NONE;
        int sock = -1;
        struct sockaddr_un serv_addr;
        ms_sock_info_s sock_info;
+       thumbRawReq *req_manager = NULL;
        int pid;
        sock_info.port = MS_THUMB_CREATOR_PORT;
 
@@ -667,35 +863,30 @@ int _media_thumb_request_raw_data_async(int msg_type, int request_id, const char
 
        /* Connecting to the thumbnail server */
        if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
-               thumb_err("connect error : %s", strerror(errno));
+               thumb_stderror("connect error");
                g_io_channel_shutdown(channel, TRUE, NULL);
                g_io_channel_unref(channel);
                return MS_MEDIA_ERR_SOCKET_CONN;
        }
 
-       if (msg_type != THUMB_REQUEST_CANCEL_RAW_DATA) {
-               /* Create new channel to watch udp socket */
-               GSource *source = NULL;
-               source = g_io_create_watch(channel, G_IO_IN);
-
-               /* Set callback to be called when socket is readable */
-               /*NEED UPDATE SOCKET FILE DELETE*/
-               g_source_set_callback(source, (GSourceFunc)_media_thumb_raw_data_write_socket, userData, NULL);
-               source_id = g_source_attach(source, g_main_context_get_thread_default());
-       }
+       req_manager = (thumbRawReq *)g_queue_pop_head(g_manage_raw_queue);
+       GSource *source = NULL;
+       source = g_io_create_watch(channel, G_IO_IN);
+       g_source_set_callback(source, (GSourceFunc)_media_thumb_raw_data_write_socket, req_manager->userData, NULL);
+       source_id = g_source_attach(source, g_main_context_get_thread_default());
 
        thumbMsg req_msg;
        memset((void *)&req_msg, 0, sizeof(thumbMsg));
 
        pid = getpid();
        req_msg.pid = pid;
-       req_msg.msg_type = msg_type;
-       req_msg.request_id = request_id;
-       req_msg.thumb_width = width;
-       req_msg.thumb_height = height;
-       req_msg.uid = uid;
+       req_msg.msg_type = req_manager->msg_type;
+       req_msg.request_id = req_manager->request_id;
+       req_msg.thumb_width = req_manager->width;
+       req_msg.thumb_height = req_manager->height;
+       req_msg.uid = req_manager->uid;
 
-       strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
+       strncpy(req_msg.org_path, req_manager->path, sizeof(req_msg.org_path));
        req_msg.org_path[strlen(req_msg.org_path)] = '\0';
        req_msg.dst_path[0] = '\0';
 
@@ -724,27 +915,229 @@ int _media_thumb_request_raw_data_async(int msg_type, int request_id, const char
        }
 
        SAFE_FREE(buf);
-       thumb_dbg("Sending msg to thumbnail daemon is successful");
 
-       if (msg_type == THUMB_REQUEST_CANCEL_RAW_DATA) {
-               g_io_channel_shutdown(channel, TRUE, NULL);
-               __media_thumb_pop_raw_data_req_queue(request_id, TRUE);
-       } else if (msg_type == THUMB_REQUEST_RAW_DATA) {
-               if (g_request_queue == NULL) {
-                       g_request_queue = g_queue_new();
+       if (req_manager->msg_type == THUMB_REQUEST_RAW_DATA) {
+               if (g_request_raw_queue == NULL) {
+                       g_request_raw_queue = g_queue_new();
                }
                thumbRawReq *thumb_req = NULL;
-               thumb_req = calloc(1, sizeof(thumbReq));
+               THUMB_MALLOC(thumb_req, sizeof(thumbRawReq));
                if (thumb_req == NULL) {
                        thumb_err("Failed to create request element");
                        return MS_MEDIA_ERR_INVALID_PARAMETER;
                }
                thumb_req->channel = channel;
-               thumb_req->request_id = request_id;
+               thumb_req->request_id = req_manager->request_id;
                thumb_req->source_id = source_id;
-               thumb_req->userData = userData;
+               thumb_req->userData = req_manager->userData;
 
-               g_queue_push_tail(g_request_queue, (gpointer)thumb_req);
+               g_queue_push_tail(g_request_raw_queue, (gpointer)thumb_req);
        }
        return MS_MEDIA_ERR_NONE;
 }
+
+int _media_thumb_request_async(int msg_type, const char *origin_path, thumbUserData *userData, uid_t uid)
+{
+       int err = MS_MEDIA_ERR_NONE;
+
+       if(g_manage_queue == NULL) {
+               if(msg_type == THUMB_REQUEST_CANCEL_MEDIA)
+                       return MS_MEDIA_ERR_INTERNAL;
+
+               g_manage_queue = g_queue_new();
+
+               thumbReq *thumb_req = NULL;
+               THUMB_MALLOC(thumb_req, sizeof(thumbReq));
+               if (thumb_req == NULL) {
+                       thumb_err("Failed to create request element");
+                       return MS_MEDIA_ERR_INVALID_PARAMETER;
+               }
+
+               thumb_req->msg_type = msg_type;
+               thumb_req->path = strdup(origin_path);
+               thumb_req->userData = userData;
+               thumb_req->isCanceled = false;
+               thumb_req->uid = uid;
+
+               g_queue_push_tail(g_manage_queue, (gpointer)thumb_req);
+
+               /* directly request at first time */
+               err = _media_thumb_send_request();
+
+       } else {
+               if(msg_type != THUMB_REQUEST_CANCEL_MEDIA) {
+                       /* Enqueue */
+                       if ((msg_type == THUMB_REQUEST_DB_INSERT) && (__media_thumb_check_req_queue(origin_path) < 0)) {
+                               thumb_err("duplicated request");
+                               return MS_MEDIA_ERR_THUMB_DUPLICATED_REQUEST;
+                       }
+
+                       thumbReq *thumb_req = NULL;
+                       THUMB_MALLOC(thumb_req, sizeof(thumbReq));
+                       if (thumb_req == NULL) {
+                               thumb_err("Failed to create request element");
+                               return MS_MEDIA_ERR_INVALID_PARAMETER;
+                       }
+
+                       thumb_req->msg_type = msg_type;
+                       thumb_req->path = strdup(origin_path);
+                       thumb_req->userData = userData;
+                       thumb_req->isCanceled = false;
+                       thumb_req->uid = uid;
+
+                       g_queue_push_tail(g_manage_queue, (gpointer)thumb_req);
+               } else {
+                       /* Dequeue */
+                       err = __media_thumb_pop_manage_queue(origin_path);
+               }
+       }
+
+       return err;
+}
+
+int _media_thumb_request_raw_data_async(int msg_type, int request_id, const char *origin_path, int width, int height, thumbRawUserData *userData, uid_t uid)
+{
+       int err = MS_MEDIA_ERR_NONE;
+
+       if(g_manage_raw_queue == NULL) {
+               if(msg_type == THUMB_REQUEST_CANCEL_RAW_DATA)
+                       return MS_MEDIA_ERR_INTERNAL;
+
+               g_manage_raw_queue = g_queue_new();
+
+               thumbRawReq *thumb_req = NULL;
+               THUMB_MALLOC(thumb_req, sizeof(thumbRawReq));
+               if (thumb_req == NULL) {
+                       thumb_err("Failed to create request element");
+                       return MS_MEDIA_ERR_INVALID_PARAMETER;
+               }
+
+               thumb_req->msg_type = msg_type;
+               thumb_req->request_id = request_id;
+               thumb_req->path = strdup(origin_path);
+               thumb_req->width = width;
+               thumb_req->height= height;
+               thumb_req->userData = userData;
+               thumb_req->isCanceled = false;
+               thumb_req->uid = uid;
+
+               g_queue_push_tail(g_manage_raw_queue, (gpointer)thumb_req);
+
+               /* directly request at first time */
+               err = _media_thumb_raw_data_send_request();
+
+       } else {
+               if(msg_type != THUMB_REQUEST_CANCEL_RAW_DATA) {
+                       /* Enqueue */
+                       thumbRawReq *thumb_req = NULL;
+                       THUMB_MALLOC(thumb_req, sizeof(thumbRawReq));
+                       if (thumb_req == NULL) {
+                               thumb_err("Failed to create request element");
+                               return MS_MEDIA_ERR_INVALID_PARAMETER;
+                       }
+
+                       thumb_req->msg_type = msg_type;
+                       thumb_req->request_id = request_id;
+                       thumb_req->path = strdup(origin_path);
+                       thumb_req->width = width;
+                       thumb_req->height= height;
+                       thumb_req->userData = userData;
+                       thumb_req->isCanceled = false;
+                       thumb_req->uid = uid;
+
+                       g_queue_push_tail(g_manage_raw_queue, (gpointer)thumb_req);
+
+               } else {
+                       /* Dequeue */
+                       err = __media_thumb_pop_raw_data_manage_queue(request_id);
+               }
+       }
+
+       return err;
+}
+
+int _media_thumb_request_cancel_all(bool isRaw) {
+       int i;
+       int req_len = -1;
+       int len = 0;
+
+       if(isRaw) {
+               thumbRawReq *tmp_raw_req = NULL;
+               if(g_manage_raw_queue == NULL) {
+                       thumb_err("manage_queue is NULL");
+                       if(g_request_raw_queue != NULL) {
+                               /* Check request queue */
+                               len = g_queue_get_length(g_request_raw_queue);
+                               if(len > 0) {
+                                       tmp_raw_req = g_queue_peek_head(g_request_raw_queue);
+                                       if (tmp_raw_req != NULL)
+                                               tmp_raw_req->isCanceled = true;
+                                       return MS_MEDIA_ERR_NONE;
+                               }
+                       }
+                       thumb_err("request_queue is NULL");
+                       return MS_MEDIA_ERR_INTERNAL;
+               }
+               req_len = g_queue_get_length(g_manage_raw_queue);
+               for(i=0;i<req_len;i++) {
+                       tmp_raw_req = g_queue_pop_tail(g_manage_raw_queue);
+                       if(tmp_raw_req) {
+                               SAFE_FREE(tmp_raw_req->path);
+                               SAFE_FREE(tmp_raw_req->userData);
+                               SAFE_FREE(tmp_raw_req);
+                               tmp_raw_req = NULL;
+                       }
+               }
+               g_queue_free (g_manage_raw_queue);
+               g_manage_raw_queue = NULL;
+               if(g_request_raw_queue != NULL) {
+                       /* Check request queue */
+                       len = g_queue_get_length(g_request_raw_queue);
+                       if(len > 0) {
+                               tmp_raw_req = g_queue_peek_head(g_request_raw_queue);
+                               if (tmp_raw_req != NULL)
+                                       tmp_raw_req->isCanceled = true;
+                       }
+               }
+       } else {
+               thumbReq *tmp_req = NULL;
+               if(g_manage_queue == NULL) {
+                       thumb_err("manage_queue is NULL");
+                       if(g_request_queue != NULL) {
+                               /* Check request queue */
+                               len = g_queue_get_length(g_request_queue);
+                               if(len > 0) {
+                                       tmp_req = g_queue_peek_head(g_request_queue);
+                                       if (tmp_req != NULL)
+                                               tmp_req->isCanceled = true;
+                                       return MS_MEDIA_ERR_NONE;
+                               }
+                       }
+                       thumb_err("request_queue is NULL");
+                       return MS_MEDIA_ERR_INTERNAL;
+               }
+               req_len = g_queue_get_length(g_manage_queue);
+               for(i=0;i<req_len;i++) {
+                       tmp_req = g_queue_pop_tail(g_manage_queue);
+                       if(tmp_req) {
+                               SAFE_FREE(tmp_req->path);
+                               SAFE_FREE(tmp_req->userData);
+                               SAFE_FREE(tmp_req);
+                               tmp_req = NULL;
+                       }
+               }
+               g_queue_free (g_manage_queue);
+               g_manage_queue = NULL;
+               if(g_request_queue != NULL) {
+                       /* Check request queue */
+                       len = g_queue_get_length(g_request_queue);
+                       if(len > 0) {
+                               tmp_req = g_queue_peek_head(g_request_queue);
+                               if (tmp_req != NULL)
+                                       tmp_req->isCanceled = true;
+                       }
+               }
+       }
+
+       return MS_MEDIA_ERR_NONE;
+}
\ No newline at end of file
index 69a1175..1e379b6 100755 (executable)
@@ -48,7 +48,6 @@
 #include <grp.h>
 #include <pwd.h>
 
-#define GLOBAL_USER    0 //#define     tzplatform_getenv(TZ_GLOBAL) //TODO
 #define MEDIA_THUMB_ROUND_UP_8(num) (((num)+7)&~7)
 
 int _media_thumb_resize_data(unsigned char *src_data,
@@ -423,6 +422,11 @@ int _media_thumb_resize_data(unsigned char *src_data,
 
        unsigned char *dst = (unsigned char *)malloc(buf_size);
 
+       if (dst == NULL) {
+               thumb_err("malloc fails");
+               return MS_MEDIA_ERR_OUT_OF_MEMORY;
+       }
+
        if (mm_util_resize_image((unsigned char *)src_data, src_width,
                        src_height, src_format,
                        dst, (unsigned int *)&thumb_width,
@@ -442,6 +446,7 @@ int _media_thumb_resize_data(unsigned char *src_data,
                memcpy(thumb_info->data, dst, buf_size);
        } else {
                thumb_err("malloc fails");
+               SAFE_FREE(dst);
                return MS_MEDIA_ERR_OUT_OF_MEMORY;
        }
        SAFE_FREE(dst);
index e5f6c2b..dd16356 100755 (executable)
@@ -165,15 +165,7 @@ int thumbnail_request_extract_raw_data_async(int request_id, const char *origin_
        return MS_MEDIA_ERR_NONE;
 }
 
-int _media_thumbnail_cancel_cb(int error_code, char* path, void* data)
-{
-       thumb_dbg("Error code : %d", error_code);
-       if (path) thumb_dbg_slog("Cancel : %s", path);
-
-       return MS_MEDIA_ERR_NONE;
-}
-
-int thumbnail_request_cancel_media(const char *origin_path, uid_t uid)
+int thumbnail_request_cancel_media(const char *origin_path)
 {
        int err = MS_MEDIA_ERR_NONE;
 
@@ -182,7 +174,7 @@ int thumbnail_request_cancel_media(const char *origin_path, uid_t uid)
                return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
 
-       err = _media_thumb_request_async(THUMB_REQUEST_CANCEL_MEDIA,  origin_path, NULL, uid);
+       err = _media_thumb_request_async(THUMB_REQUEST_CANCEL_MEDIA,  origin_path, NULL, 0);
        if (err != MS_MEDIA_ERR_NONE) {
                thumb_err("_media_thumb_request failed : %d", err);
                return err;
@@ -191,17 +183,16 @@ int thumbnail_request_cancel_media(const char *origin_path, uid_t uid)
        return MS_MEDIA_ERR_NONE;
 }
 
-int thumbnail_request_cancel_raw_data(int request_id, uid_t uid)
+int thumbnail_request_cancel_raw_data(int request_id)
 {
        int err = MS_MEDIA_ERR_NONE;
-       const char *dummy_str = "dummy";
 
        if (request_id == 0) {
                thumb_err("Invalid parameter");
                return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
 
-       err = _media_thumb_request_raw_data_async(THUMB_REQUEST_CANCEL_RAW_DATA, request_id, dummy_str, 0, 0, NULL, uid);
+       err = _media_thumb_request_raw_data_async(THUMB_REQUEST_CANCEL_RAW_DATA, request_id, NULL, 0, 0, NULL, 0);
        if (err != MS_MEDIA_ERR_NONE) {
                thumb_err("_media_thumb_request failed : %d", err);
                return err;
@@ -210,24 +201,15 @@ int thumbnail_request_cancel_raw_data(int request_id, uid_t uid)
        return MS_MEDIA_ERR_NONE;
 }
 
-int thumbnail_request_cancel_all(bool is_raw_data, uid_t uid)
+int thumbnail_request_cancel_all(bool is_raw_data)
 {
        int err = MS_MEDIA_ERR_NONE;
 
-       media_thumb_info thumb_info;
-       char tmp_origin_path[MAX_PATH_SIZE] = {0,};
-       char tmp_thumb_path[MAX_PATH_SIZE] = {0,};
-
-       /* Request for thumb file to the daemon "Thumbnail generator" */
        if(is_raw_data) {
-               err = _media_thumb_request(THUMB_REQUEST_CANCEL_ALL_RAW_DATA, tmp_origin_path, tmp_thumb_path, sizeof(tmp_thumb_path), &thumb_info, uid);
+               err = _media_thumb_request_cancel_all(true);
        } else {
-               err = _media_thumb_request(THUMB_REQUEST_CANCEL_ALL, tmp_origin_path, tmp_thumb_path, sizeof(tmp_thumb_path), &thumb_info, uid);
-       }
-       if (err != MS_MEDIA_ERR_NONE) {
-               thumb_err("_media_thumb_request failed : %d", err);
-               return err;
+               err = _media_thumb_request_cancel_all(false);
        }
 
-       return MS_MEDIA_ERR_NONE;
+       return err;
 }
index 92919cd..d1c49f1 100755 (executable)
@@ -179,7 +179,7 @@ int main(int argc, char *argv[])
        } else if (mode == 6) {
                printf("Test thumbnail_request_cancel_media\n");
 
-               err = thumbnail_request_cancel_media(origin_path,tzplatform_getuid(TZ_USER_NAME));
+               err = thumbnail_request_cancel_media(origin_path);
                if (err < 0) {
                        printf("thumbnail_request_cancel_media failed : %d\n", err);
                        return -1;
@@ -189,7 +189,7 @@ int main(int argc, char *argv[])
        } else if (mode == 7) {
                printf("Test thumbnail_request_cancel_all\n");
 
-               err = thumbnail_request_cancel_all(true, tzplatform_getuid(TZ_USER_NAME));
+               err = thumbnail_request_cancel_all(true);
                if (err < 0) {
                        printf("thumbnail_request_cancel_all failed : %d\n", err);
                        return -1;