summaryrefslogtreecommitdiff
path: root/server/thumb-server-internal.c
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2018-03-07 16:36:24 +0900
committerMinje Ahn <minje.ahn@samsung.com>2018-03-07 16:36:24 +0900
commitf2c27307d527ecc96fd94a61b5c443c44e45ad05 (patch)
tree073173858d9913d29a48f1b291eca1936b69627f /server/thumb-server-internal.c
parent082f108bc92d609a72046a401f1b31ef1c21479f (diff)
downloadlibmedia-thumbnail-f2c27307d527ecc96fd94a61b5c443c44e45ad05.tar.gz
libmedia-thumbnail-f2c27307d527ecc96fd94a61b5c443c44e45ad05.tar.bz2
libmedia-thumbnail-f2c27307d527ecc96fd94a61b5c443c44e45ad05.zip
1. Modified result compare 2. Remove response for kill-msg 3. Remove block send Change-Id: Idde2423e5054e9813a746ee89779aaee35a62f8d Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'server/thumb-server-internal.c')
-rwxr-xr-xserver/thumb-server-internal.c49
1 files changed, 23 insertions, 26 deletions
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index e15ee8d..5a279d4 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -37,7 +37,6 @@
#define LOG_TAG "MEDIA_THUMBNAIL_SERVER"
#define THUMB_DEFAULT_WIDTH 320
#define THUMB_DEFAULT_HEIGHT 240
-#define THUMB_BLOCK_SIZE 512
#define THUMB_COMM_SOCK_PATH tzplatform_mkpath(TZ_SYS_RUN, "media-server/media_ipc_thumbcomm.socket")
#define THUMB_EMPTY_STR ""
@@ -112,6 +111,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);
@@ -119,8 +123,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;
@@ -132,35 +135,29 @@ gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpoi
res_msg.dst_path[0] = '\0';
int buf_size = 0;
- int sending_block = 0;
- int block_size = sizeof(res_msg) - sizeof(unsigned char *);
+ int remain_size = 0;
+ int head_size = sizeof(res_msg) - sizeof(unsigned char *);
unsigned char *buf = NULL;
_media_thumb_set_buffer(&res_msg, &buf, &buf_size);
+ remain_size = buf_size - head_size;
- while (buf_size > 0) {
- 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, head_size, 0) < 0) {
+ thumb_stderror("send failed");
+ } else {
+ if (remain_size > 0) {
+ if (send(client_sock, buf + head_size, remain_size, 0) < 0) {
+ thumb_stderror("send failed");
+ } else {
+ thumb_dbg_slog("Sent data(%d) from %s", res_msg.thumb_size, res_msg.org_path);
+ }
+ } else {
+ thumb_dbg_slog("Sent thumbnail(%s) from %s", res_msg.dst_path, res_msg.org_path);
}
-
- sending_block += block_size;
- buf_size -= block_size;
- if (block_size < THUMB_BLOCK_SIZE)
- 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;
@@ -191,8 +188,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;
}
@@ -211,7 +208,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;
}