Fix bug that controller daemon(On-demand) was not terminated sometimes 84/64584/3 accepted/tizen/common/20160407.132630 accepted/tizen/ivi/20160407.111518 accepted/tizen/mobile/20160407.111421 accepted/tizen/tv/20160407.111432 accepted/tizen/wearable/20160407.111449 submit/tizen/20160407.055809
authorJiyong Min <jiyong.min@samsung.com>
Mon, 4 Apr 2016 02:06:13 +0000 (11:06 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Tue, 5 Apr 2016 01:07:14 +0000 (18:07 -0700)
Change-Id: Ibde89fa040deaae2b9d646fa7db5be8ee09b8657
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
packaging/capi-media-controller.spec [changed mode: 0755->0644]
packaging/mediacontroller.socket [changed mode: 0755->0644]
src/media_controller_ipc.c [changed mode: 0755->0644]
svc/daemon/media_controller_main.c [changed mode: 0755->0644]
svc/media_controller_socket.c [changed mode: 0755->0644]
svc/media_controller_socket.h [changed mode: 0755->0644]
svc/media_controller_svc.c [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index dc773be..cfd3f39
@@ -1,6 +1,6 @@
 Name:       capi-media-controller
 Summary:    A media controller library in Tizen Native API
-Version:    0.0.16
+Version:    0.0.17
 Release:    1
 Group:      Multimedia/API
 License:    Apache-2.0
old mode 100755 (executable)
new mode 100644 (file)
index 81da5b6..e1db656
@@ -4,7 +4,7 @@ Description=MediaController Service socket
 [Socket]
 SocketUser=system
 SocketGroup=system
-ListenStream=/var/run/media-controller/media_ipc_controller
+ListenStream=/var/run/media-controller/media_sa_controller
 Service=mediacontroller.service
 
 [Install]
old mode 100755 (executable)
new mode 100644 (file)
index 66a3222..ebb8cb1
@@ -404,7 +404,7 @@ int mc_ipc_service_connect(void)
        /*Set server Address*/
        memset(&serv_addr, 0, sizeof(serv_addr));
        serv_addr.sun_family = AF_UNIX;
-       strncpy(serv_addr.sun_path, MC_IPC_PATH, sizeof(serv_addr.sun_path) - 1);
+       strncpy(serv_addr.sun_path, MC_SOCK_ACTIVATION_PATH, sizeof(serv_addr.sun_path) - 1);
 
        /* Connecting to the media controller service */
        if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
old mode 100755 (executable)
new mode 100644 (file)
index 6679a77..5f20c55
@@ -22,7 +22,7 @@
 GMainLoop *g_mc_mainloop = NULL;
 static int g_mc_timer_id = 0;
 
-#define MC_MAIN_TIMEOUT_SEC_60 600
+#define MC_MAIN_TIMEOUT_SEC_60 60
 
 
 void __mc_main_create_timer(int timer_id);
@@ -64,6 +64,9 @@ int main(int argc, char **argv)
 {
        GThread *svc_thread = NULL;
        int fd = -1;
+       int client_fd = -1;
+       struct sockaddr_in client_addr;
+       int client_addr_size = 0;
 
        /*Init main loop*/
        g_mc_mainloop = g_main_loop_new(NULL, FALSE);
@@ -74,8 +77,14 @@ int main(int argc, char **argv)
        }
 
        fd = mc_create_socket_activation();
-       if (fd < 0)
+       if (fd < 0) {
                mc_error("Failed to socekt creation");
+       } else {
+               client_addr_size = sizeof(client_addr);
+               client_fd = accept(fd, (struct sockaddr*)&client_addr, (socklen_t *)&client_addr_size);
+               if (client_fd == -1)
+                       mc_error("accept failed");
+       }
 
        /*create each threads*/
        svc_thread  = g_thread_new("mc_svc_thread", (GThreadFunc)mc_svc_thread, NULL);
old mode 100755 (executable)
new mode 100644 (file)
index 648d616..a2bfde9
 #include "media_controller_db_util.h"
 #include "media_controller_socket.h"
 
-#define MC_SOCK_PATH_PRFX "/tmp/.media_ipc_mc_client"
-#define MC_SOCK_PATH_TEMPLATE "XXXXXX"
-#define MC_SOCK_PATH MC_SOCK_PATH_PRFX MC_SOCK_PATH_TEMPLATE
-#define MC_SOCK_UDP_BLOCK_SIZE 512
-
 int mc_ipc_create_client_socket(int timeout_sec, mc_sock_info_s *sock_info)
 {
        int sock = -1;
@@ -58,13 +53,16 @@ int mc_ipc_delete_client_socket(mc_sock_info_s *sock_info)
 {
        int ret = 0;
 
-       close(sock_info->sock_fd);
        mc_debug("sockfd %d close", sock_info->sock_fd);
+       if (close(sock_info->sock_fd) < 0)
+               mc_stderror("sockfd close failed");
+
        if (sock_info->sock_path != NULL) {
+#if 0
                ret = unlink(sock_info->sock_path);
                if (ret < 0)
                        mc_stderror("unlink failed");
-
+#endif
                free(sock_info->sock_path);
        }
 
old mode 100755 (executable)
new mode 100644 (file)
index 0be7287..42e3531
@@ -29,8 +29,8 @@ extern "C" {
 #define SERVER_IP                      "127.0.0.1"
 #define MC_TIMEOUT_SEC_5                                       5               /**< Response from Server time out */
 #define MAX_MSG_SIZE                           4096*2
-#define MC_SOCK_NOT_ALLOCATE           -1
-/*#define MC_SOCK_ACTIVATION_PATH              tzplatform_mkpath(TZ_SYS_RUN, "media-controller/media_sa_controller") */
+#define MC_SOCK_NOT_ALLOCATE           -1
+#define MC_SOCK_ACTIVATION_PATH                tzplatform_mkpath(TZ_SYS_RUN, "media-controller/media_sa_controller")
 #define MC_IPC_PATH                                    tzplatform_mkpath(TZ_SYS_RUN, "media-controller/media_ipc_controller")
 #define MC_SERVER_CONNECTION_MSG                       "Connect"
 #define MC_SERVER_DISCONNECTION_MSG            "Disonnect"
old mode 100755 (executable)
new mode 100644 (file)
index e7ab9af..46ad57b
@@ -392,6 +392,7 @@ gboolean mc_svc_thread(void *data)
 
        g_io_channel_shutdown(channel, FALSE, NULL);
        g_io_channel_unref(channel);
+       g_source_unref(source);
 
        if (mc_svc_data->mc_svc_list != NULL)
                g_list_free_full(mc_svc_data->mc_svc_list, _mc_svc_destroy_data);