summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2017-05-22 10:27:47 (GMT)
committerMinje Ahn <minje.ahn@samsung.com>2017-05-22 10:31:20 (GMT)
commit34ed08a8f899bffe2f9b27b4bd2e6e180650e61c (patch)
tree0666a10475afbece31105dfb3ef7d0fb3437e4eb
parentbddb7b6537d4d96c29c3343ce454a1b1462c07a4 (diff)
downloadlibmedia-thumbnail-34ed08a8f899bffe2f9b27b4bd2e6e180650e61c.zip
libmedia-thumbnail-34ed08a8f899bffe2f9b27b4bd2e6e180650e61c.tar.gz
libmedia-thumbnail-34ed08a8f899bffe2f9b27b4bd2e6e180650e61c.tar.bz2
Remove socket path and structure Change-Id: I5ced06aa5e575d37d79017e8854d1eb9d8415325 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
-rwxr-xr-xserver/thumb-server-internal.c22
-rwxr-xr-xserver/thumb-server.c14
-rwxr-xr-xsrc/include/util/media-thumb-db.h13
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c37
4 files changed, 21 insertions, 65 deletions
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index 35e87ba..dc921d6 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -205,19 +205,16 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
static gboolean __thumb_server_send_msg_to_agent(int msg_type)
{
int sock;
- ms_sock_info_s sock_info;
struct sockaddr_un serv_addr;
ms_thumb_server_msg send_msg;
- sock_info.port = MS_THUMB_COMM_PORT;
- if (ms_ipc_create_client_socket(MS_TIMEOUT_SEC_10, &sock_info) < 0) {
+ if (ms_ipc_create_client_socket(MS_TIMEOUT_SEC_10, &sock) < 0) {
thumb_err("ms_ipc_create_server_socket failed");
return FALSE;
}
memset(&serv_addr, 0, sizeof(serv_addr));
- sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
SAFE_STRLCPY(serv_addr.sun_path, THUMB_COMM_SOCK_PATH, sizeof(serv_addr.sun_path));
@@ -225,7 +222,7 @@ static gboolean __thumb_server_send_msg_to_agent(int msg_type)
/* Connecting to the thumbnail server */
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
thumb_stderror("connect");
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
return MS_MEDIA_ERR_SOCKET_CONN;
}
@@ -233,13 +230,12 @@ static gboolean __thumb_server_send_msg_to_agent(int msg_type)
if (send(sock, &send_msg, sizeof(ms_thumb_server_msg), 0) != sizeof(ms_thumb_server_msg)) {
thumb_stderror("sendto failed");
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
return FALSE;
}
thumb_dbg("Sending msg to thumbnail agent[%d] is successful", send_msg.msg_type);
-
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
return TRUE;
}
@@ -263,16 +259,8 @@ static gboolean _thumb_server_send_deny_message(int sockfd)
gboolean _thumb_server_prepare_socket(int *sock_fd)
{
int sock;
- unsigned short serv_port;
-
- thumbMsg recv_msg;
- thumbMsg res_msg;
-
- memset((void *)&recv_msg, 0, sizeof(recv_msg));
- memset((void *)&res_msg, 0, sizeof(res_msg));
- serv_port = MS_THUMB_DAEMON_PORT;
- if (ms_ipc_create_server_socket(serv_port, &sock) < 0) {
+ if (ms_ipc_create_server_socket(MS_THUMB_DAEMON_PORT, &sock) < 0) {
thumb_err("ms_ipc_create_server_socket failed");
return FALSE;
}
diff --git a/server/thumb-server.c b/server/thumb-server.c
index 2c2a02d..7de7eda 100755
--- a/server/thumb-server.c
+++ b/server/thumb-server.c
@@ -34,20 +34,6 @@
extern GMainLoop *g_thumb_server_mainloop;
-#if 0
-static void _media_thumb_signal_handler(void *user_data)
-{
- thumb_dbg("Singal Hander for HEYNOTI \"power_off_start\"");
-
- if (g_thumb_server_mainloop)
- g_main_loop_quit(g_thumb_server_mainloop);
- else
- exit(1);
-
- return;
-}
-#endif
-
int main(void)
{
int sockfd = -1;
diff --git a/src/include/util/media-thumb-db.h b/src/include/util/media-thumb-db.h
index b3d2d71..6a5b64c 100755
--- a/src/include/util/media-thumb-db.h
+++ b/src/include/util/media-thumb-db.h
@@ -25,31 +25,22 @@
#ifndef _MEDIA_THUMB_DB_H_
#define _MEDIA_THUMB_DB_H_
-#define STRING_VALID(str) \
- ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
+#define STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
#define SELECT_THUMB_BY_PATH "SELECT thumbnail_path, width, height FROM media WHERE path='%q';"
#define UPDATE_THUMB_BY_PATH "UPDATE media SET thumbnail_path = '%q' WHERE path='%q';"
#define UPDATE_THUMB_WH_BY_PATH "UPDATE media SET thumbnail_path = '%q', width=%d,height=%d WHERE path='%q';"
sqlite3 *_media_thumb_db_get_handle();
-
int _media_thumb_db_connect(uid_t uid);
-
int _media_thumb_db_disconnect();
-
int _media_thumb_get_thumb_from_db_with_size(const char *origin_path,
char *thumb_path,
int max_length,
int *need_update_db,
int *width,
int *height);
-
-int _media_thumb_update_db(const char *origin_path,
- char *thumb_path,
- int width,
- int height,
- uid_t uid);
+int _media_thumb_update_db(const char *origin_path, char *thumb_path, int width, int height, uid_t uid);
#endif /*_MEDIA_THUMB_DB_H_*/
diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c
index 3238092..e86658c 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -545,27 +545,24 @@ _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, in
{
int sock = -1;
struct sockaddr_un serv_addr;
- ms_sock_info_s sock_info;
int recv_str_len = 0;
int err = MS_MEDIA_ERR_NONE;
int pid;
- sock_info.port = MS_THUMB_CREATOR_PORT;
- err = ms_ipc_create_client_socket(MS_TIMEOUT_SEC_10, &sock_info);
+ err = ms_ipc_create_client_socket(MS_TIMEOUT_SEC_10, &sock);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("ms_ipc_create_client_socket failed");
return err;
}
memset(&serv_addr, 0, sizeof(serv_addr));
- sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
SAFE_STRLCPY(serv_addr.sun_path, THUMB_IPC_PATH, sizeof(serv_addr.sun_path));
/* Connecting to the thumbnail server */
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
thumb_stderror("connect");
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
return MS_MEDIA_ERR_SOCKET_CONN;
}
@@ -591,7 +588,7 @@ _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, in
if (req_msg.origin_path_size > MAX_PATH_SIZE || req_msg.dest_path_size > MAX_PATH_SIZE) {
thumb_err("path's length exceeds %d", MAX_PATH_SIZE);
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
@@ -605,7 +602,7 @@ _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, in
if (send(sock, buf, buf_size, 0) != buf_size) {
thumb_err("sendto failed: %d", errno);
SAFE_FREE(buf);
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
return MS_MEDIA_ERR_SOCKET_SEND;
}
@@ -615,14 +612,14 @@ _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, in
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);
+ close(sock);
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);
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
if (recv_str_len > max_length) {
thumb_err("user buffer is too small. Output's length is %d", recv_str_len);
@@ -757,19 +754,16 @@ 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;
- err = ms_ipc_create_client_socket(MS_TIMEOUT_SEC_10, &sock_info);
+ err = ms_ipc_create_client_socket(MS_TIMEOUT_SEC_10, &sock);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("ms_ipc_create_client_socket failed");
return err;
}
memset(&serv_addr, 0, sizeof(serv_addr));
- sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
SAFE_STRLCPY(serv_addr.sun_path, THUMB_IPC_PATH, sizeof(serv_addr.sun_path));
@@ -787,7 +781,7 @@ int _media_thumb_send_request()
g_io_channel_shutdown(channel, TRUE, NULL);
g_io_channel_unref(channel);
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
return err;
}
@@ -798,7 +792,7 @@ int _media_thumb_send_request()
thumb_err("queue pop fail");
g_io_channel_shutdown(channel, TRUE, NULL);
g_io_channel_unref(channel);
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
@@ -827,7 +821,7 @@ int _media_thumb_send_request()
thumb_err("path's length exceeds %d", MAX_PATH_SIZE);
g_io_channel_shutdown(channel, TRUE, NULL);
g_io_channel_unref(channel);
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
@@ -841,7 +835,7 @@ int _media_thumb_send_request()
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);
g_io_channel_unref(channel);
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
return MS_MEDIA_ERR_SOCKET_SEND;
}
@@ -877,19 +871,16 @@ 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;
- err = ms_ipc_create_client_socket(MS_TIMEOUT_SEC_10, &sock_info);
+ err = ms_ipc_create_client_socket(MS_TIMEOUT_SEC_10, &sock);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("ms_ipc_create_client_socket failed");
return err;
}
memset(&serv_addr, 0, sizeof(serv_addr));
- sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
SAFE_STRLCPY(serv_addr.sun_path, THUMB_IPC_PATH, sizeof(serv_addr.sun_path));
@@ -907,7 +898,7 @@ int _media_thumb_raw_data_send_request()
g_io_channel_shutdown(channel, TRUE, NULL);
g_io_channel_unref(channel);
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
return err;
}
@@ -917,7 +908,7 @@ int _media_thumb_raw_data_send_request()
thumb_err("queue pop fail");
g_io_channel_shutdown(channel, TRUE, NULL);
g_io_channel_unref(channel);
- ms_ipc_delete_client_socket(&sock_info);
+ close(sock);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}