summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhj kim <backto.kim@samsung.com>2020-04-17 04:08:26 +0000
committerGerrit Code Review <gerrit@review>2020-04-17 04:08:26 +0000
commitbfb2b810db4a5c35eee884de0d7fe6bdae3ef270 (patch)
tree64265c0f93dcd287c82f2b2656e99ad30a67cbc8
parent24233670e8d5fa877de71b0a85a4ef09eeaa9df9 (diff)
parentc96dbf9631632a2b8db77a6972f5c20f8ab14acf (diff)
downloadlibmedia-thumbnail-bfb2b810db4a5c35eee884de0d7fe6bdae3ef270.tar.gz
libmedia-thumbnail-bfb2b810db4a5c35eee884de0d7fe6bdae3ef270.tar.bz2
libmedia-thumbnail-bfb2b810db4a5c35eee884de0d7fe6bdae3ef270.zip
-rwxr-xr-xserver/thumb-server-internal.c8
-rwxr-xr-xserver/thumb-server.c22
2 files changed, 9 insertions, 21 deletions
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index c3e8f9e..bd43605 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -242,7 +242,7 @@ ERROR:
return G_SOURCE_REMOVE;
}
-gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpointer data)
+gboolean _thumb_server_read_socket(GIOChannel *channel, GIOCondition condition, gpointer data)
{
struct sockaddr_un client_addr;
unsigned int client_addr_len;
@@ -263,7 +263,7 @@ gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpoi
memset((void *)&res_msg, 0, sizeof(res_msg));
memset((void *)&credentials, 0, sizeof(credentials));
- sock = g_io_channel_unix_get_fd(src);
+ sock = g_io_channel_unix_get_fd(channel);
thumb_retvm_if(sock < 0, G_SOURCE_CONTINUE, "sock fd is invalid!");
client_addr_len = sizeof(client_addr);
@@ -287,7 +287,9 @@ gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpoi
} else {
thumb_warn("Shutting down...");
g_main_loop_quit(thumb_server);
- goto ERROR;
+ close(client_sock);
+
+ return G_SOURCE_REMOVE;
}
SAFE_FREE(credentials.smack);
diff --git a/server/thumb-server.c b/server/thumb-server.c
index 3541d44..750f782 100755
--- a/server/thumb-server.c
+++ b/server/thumb-server.c
@@ -37,9 +37,7 @@ static GMainLoop *g_thumb_server_mainloop;
int main(void)
{
int sockfd = -1;
- GSource *source = NULL;
GIOChannel *channel = NULL;
- GMainContext *context = NULL;
if (ms_cynara_initialize() != MS_MEDIA_ERR_NONE) {
thumb_err("Cynara initialization failed");
@@ -52,32 +50,20 @@ int main(void)
return -1;
}
- g_thumb_server_mainloop = g_main_loop_new(context, FALSE);
- context = g_main_loop_get_context(g_thumb_server_mainloop);
+ g_thumb_server_mainloop = g_main_loop_new(NULL, FALSE);
/* Create new channel to watch tcp socket */
channel = g_io_channel_unix_new(sockfd);
- source = g_io_create_watch(channel, G_IO_IN);
-
- /* Set callback to be called when socket is readable */
- g_source_set_callback(source, (GSourceFunc)_thumb_server_read_socket, (gpointer)g_thumb_server_mainloop, NULL);
- g_source_attach(source, context);
+ g_io_add_watch(channel, G_IO_IN, _thumb_server_read_socket, g_thumb_server_mainloop);
+ g_io_channel_unref(channel);
- GSource *source_evas_init = NULL;
- source_evas_init = g_idle_source_new();
- g_source_set_callback(source_evas_init, _thumb_daemon_start_jobs, NULL, NULL);
- g_source_attach(source_evas_init, context);
+ g_idle_add(_thumb_daemon_start_jobs, NULL);
thumb_info("Thumbnail server is running");
g_main_loop_run(g_thumb_server_mainloop);
thumb_info("Thumbnail server is shutting down");
- g_io_channel_shutdown(channel, FALSE, NULL);
- g_io_channel_unref(channel);
- /*close socket*/
close(sockfd);
-
- g_main_loop_quit(g_thumb_server_mainloop);
g_main_loop_unref(g_thumb_server_mainloop);
ms_cynara_finish();