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;
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);
} else {
thumb_warn("Shutting down...");
g_main_loop_quit(thumb_server);
- goto ERROR;
+ close(client_sock);
+
+ return G_SOURCE_REMOVE;
}
SAFE_FREE(credentials.smack);
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");
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();