diff options
author | Minje Ahn <minje.ahn@samsung.com> | 2018-04-26 14:41:02 +0900 |
---|---|---|
committer | Minje Ahn <minje.ahn@samsung.com> | 2018-04-26 14:41:28 +0900 |
commit | aaa728d6ecb1b03b03c11dfd8c56d1daba0c72e4 (patch) | |
tree | ffe2b9470328fa6ea86e8bcf2631eb50e0d5f589 | |
parent | 6a4b5bc1c1956f66570f61b9c19db47ed29c7a35 (diff) | |
parent | bd703adacacd8e39c94140883cfe535ce05d3dee (diff) | |
download | libmedia-thumbnail-tizen_4.0_tv.tar.gz libmedia-thumbnail-tizen_4.0_tv.tar.bz2 libmedia-thumbnail-tizen_4.0_tv.zip |
Merge branch 'tizen_4.0' into tizen_4.0_tvtizen_4.0_tv
Change-Id: I40b9fa3261cfdcbbb0df2961d520facc540765e0
-rw-r--r-- | packaging/libmedia-thumbnail.spec | 2 | ||||
-rwxr-xr-x | server/thumb-server-internal.c | 27 | ||||
-rwxr-xr-x | src/ipc/media-thumb-ipc.c | 27 |
3 files changed, 26 insertions, 30 deletions
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec index 4515507..ea5646d 100644 --- a/packaging/libmedia-thumbnail.spec +++ b/packaging/libmedia-thumbnail.spec @@ -1,6 +1,6 @@ Name: libmedia-thumbnail Summary: Media thumbnail service library for multimedia applications -Version: 0.2.17 +Version: 0.2.18 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 and PD diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c index 117de96..16d58f3 100755 --- a/server/thumb-server-internal.c +++ b/server/thumb-server-internal.c @@ -38,7 +38,7 @@ #define LOG_TAG "MEDIA_THUMBNAIL_SERVER" #define THUMB_DEFAULT_WIDTH 320 #define THUMB_DEFAULT_HEIGHT 240 -#define THUMB_BLOCK_SIZE 512 +#define THUMB_BLOCK_SIZE 10240 #define THUMB_COMM_SOCK_PATH tzplatform_mkpath(TZ_SYS_RUN, "media-server/media_ipc_thumbcomm.socket") #define THUMB_EMPTY_STR "" @@ -125,6 +125,11 @@ gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpoi close(client_sock); return TRUE; } + } else { + thumb_warn("Shutting down..."); + g_main_loop_quit(g_thumb_server_mainloop); + close(client_sock); + return TRUE; } SAFE_FREE(credentials.smack); @@ -132,8 +137,7 @@ gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpoi thumb_warn_slog("Received [%d] %.*s(%d) from PID(%d)", recv_msg.msg_type, MAX_FILEPATH_LEN, recv_msg.org_path, strlen(recv_msg.org_path), recv_msg.pid); - if (recv_msg.msg_type != THUMB_REQUEST_KILL_SERVER) - _thumb_daemon_process_job(&recv_msg, &res_msg); + _thumb_daemon_process_job(&recv_msg, &res_msg); if (res_msg.msg_type == 0) res_msg.msg_type = recv_msg.msg_type; @@ -154,8 +158,8 @@ gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpoi if (buf_size < THUMB_BLOCK_SIZE) block_size = buf_size; - if (send(client_sock, buf+sending_block, block_size, 0) != block_size) { - thumb_stderror("sendto failed"); + if (send(client_sock, buf+sending_block, block_size, 0) < 0) { + thumb_stderror("send failed"); } sending_block += block_size; @@ -164,16 +168,9 @@ gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpoi block_size = THUMB_BLOCK_SIZE; } - thumb_dbg_slog("Sent data(%d) from %s", res_msg.thumb_size, res_msg.org_path); - SAFE_FREE(buf); SAFE_FREE(res_msg.thumb_data); - if (recv_msg.msg_type == THUMB_REQUEST_KILL_SERVER) { - thumb_warn("Shutting down..."); - g_main_loop_quit(g_thumb_server_mainloop); - } - close(client_sock); return TRUE; @@ -204,8 +201,8 @@ static gboolean __thumb_server_send_msg_to_agent(int msg_type) send_msg.msg_type = msg_type; - if (send(sock, &send_msg, sizeof(ms_thumb_server_msg), 0) != sizeof(ms_thumb_server_msg)) { - thumb_stderror("sendto failed"); + if (send(sock, &send_msg, sizeof(ms_thumb_server_msg), 0) < 0) { + thumb_stderror("send failed"); close(sock); return FALSE; } @@ -224,7 +221,7 @@ static gboolean _thumb_server_send_deny_message(int sockfd) msg.msg_type = THUMB_RESPONSE; msg.status = MS_MEDIA_ERR_PERMISSION_DENIED; - if (send(sockfd, &msg, bytes_to_send, 0) != bytes_to_send) { + if (send(sockfd, &msg, bytes_to_send, 0) < 0) { thumb_stderror("send failed"); return FALSE; } diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c index 1b9393d..b092cea 100755 --- a/src/ipc/media-thumb-ipc.c +++ b/src/ipc/media-thumb-ipc.c @@ -31,7 +31,7 @@ #include <grp.h> #include <pwd.h> -#define THUMB_SOCK_BLOCK_SIZE 512 +#define THUMB_SOCK_BLOCK_SIZE 10240 #define THUMB_IPC_PATH tzplatform_mkpath(TZ_SYS_RUN, "media-server/media_ipc_thumbcreator.socket") static GQueue *g_manage_queue = NULL; @@ -246,7 +246,6 @@ bool __media_thumb_check_cancel_for_raw(void) int _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg) { - int recv_msg_len = 0; int remain_size = 0; int block_size = THUMB_SOCK_BLOCK_SIZE; int recv_block = 0; @@ -262,7 +261,7 @@ int _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg) return MS_MEDIA_ERR_OUT_OF_MEMORY; } - if ((recv_msg_len = recv(sock, buf, header_size, 0)) <= 0) { + if (recv(sock, buf, header_size, 0) < 0) { thumb_stderror("recv failed"); SAFE_FREE(buf); SAFE_FREE(block_buf); @@ -270,21 +269,21 @@ int _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg) } memcpy(msg, buf, header_size); + SAFE_FREE(buf); if (strlen(msg->org_path) == 0 || strlen(msg->org_path) >= MAX_FILEPATH_LEN) { thumb_err("org_path size is invalid %d", strlen(msg->org_path)); - + SAFE_FREE(block_buf); return MS_MEDIA_ERR_SOCKET_RECEIVE; } /* it can be empty string */ if (strlen(msg->dst_path) >= MAX_FILEPATH_LEN) { thumb_err("dst_path size is invalid %d", strlen(msg->dst_path)); - + SAFE_FREE(block_buf); return MS_MEDIA_ERR_SOCKET_RECEIVE; } - SAFE_FREE(buf); if (msg->thumb_size < 0) { thumb_err("recv data is wrong"); SAFE_FREE(block_buf); @@ -303,7 +302,7 @@ int _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg) if (remain_size < THUMB_SOCK_BLOCK_SIZE) { block_size = remain_size; } - if ((recv_msg_len = recv(sock, block_buf, block_size, 0)) < 0) { + if (recv(sock, block_buf, block_size, 0) < 0) { thumb_stderror("recv failed"); SAFE_FREE(buf); SAFE_FREE(block_buf); @@ -366,6 +365,7 @@ int _media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_siz int _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, int max_length, uid_t uid) { int sock = -1; + int header_size = 0; struct sockaddr_un serv_addr; int recv_str_len = 0; int err = MS_MEDIA_ERR_NONE; @@ -406,12 +406,11 @@ int _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path unsigned char *buf = NULL; int buf_size = 0; - int header_size = 0; - header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2 - sizeof(unsigned char *); + header_size = sizeof(thumbMsg) - sizeof(unsigned char *); _media_thumb_set_buffer(&req_msg, &buf, &buf_size); - if (send(sock, buf, buf_size, 0) != buf_size) { + if (send(sock, buf, buf_size, 0) < 0) { thumb_err("sendto failed: %d", errno); SAFE_FREE(buf); close(sock); @@ -599,8 +598,8 @@ static int _media_thumb_send_request() int buf_size = 0; _media_thumb_set_buffer(&req_msg, &buf, &buf_size); - if (send(sock, buf, buf_size, 0) != buf_size) { - thumb_err("sendto failed: %d", errno); + if (send(sock, buf, buf_size, 0) < 0) { + thumb_err("send failed: %d", errno); SAFE_FREE(buf); g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), source_id)); g_io_channel_shutdown(channel, TRUE, NULL); @@ -691,8 +690,8 @@ static int _media_thumb_raw_data_send_request() int buf_size = 0; _media_thumb_set_buffer(&req_msg, &buf, &buf_size); - if (send(sock, buf, buf_size, 0) != buf_size) { - thumb_err("sendto failed: %d", errno); + if (send(sock, buf, buf_size, 0) < 0) { + thumb_err("send failed: %d", errno); SAFE_FREE(buf); g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), source_id)); g_io_channel_shutdown(channel, TRUE, NULL); |