Create a file to verify controller daemon has run 17/317217/4 accepted/tizen_unified_x_asan accepted/tizen/unified/20241231.131846 accepted/tizen/unified/x/20250101.065006 accepted/tizen/unified/x/asan/20250113.002101
authorhjkim <backto.kim@samsung.com>
Fri, 27 Dec 2024 05:10:08 +0000 (14:10 +0900)
committerhjkim <backto.kim@samsung.com>
Tue, 31 Dec 2024 01:23:53 +0000 (10:23 +0900)
create tmp/media_controller_launch and remain additional message when socket connection failed.

Change-Id: I8b324119f9a2f944f7db85cea3f4a885af20fc27

packaging/capi-media-controller.spec
svc/daemon/media_controller_main.c
svc/include/media_controller_svc.h
svc/media_controller_socket.c

index ba2b29b701ef7de625ddf89d9b1c089774033da7..8268605a17c234e929042b4d2bd0ceb64e4a43d7 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-controller
 Summary:    A media controller library in Tizen Native API
-Version:    1.0.8
+Version:    1.0.9
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 796206ecc503db47c1760dcbdb2a59a2fe853136..89ce1da35ef70bd186c4b0587cf749fbc0b0aad9 100644 (file)
@@ -14,6 +14,9 @@
 * limitations under the License.
 */
 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #include <systemd/sd-daemon.h>
 
 #include "media_controller_private.h"
@@ -28,7 +31,6 @@ static int g_mc_timer_id = 0;
 
 #define MC_MAIN_TIMEOUT_SEC_60 60
 
-
 static void __mc_main_create_timer(void);
 
 static gboolean __mc_main_check_connection(gpointer user_data)
@@ -85,6 +87,19 @@ static int __mc_main_listen_socket(void)
        }
 }
 
+static void __mc_main_create_daemon_launch_check_file(void)
+{
+       int fd;
+
+       if ((fd = creat(LAUNCH_CHECK_FILE, 0644)) < 0) {
+               mc_stderror("failed to create file");
+               return;
+       }
+
+       mc_debug("[%s] is created", LAUNCH_CHECK_FILE);
+       close(fd);
+}
+
 int main(int argc, char **argv)
 {
        GThread *svc_thread = NULL;
@@ -129,6 +144,7 @@ int main(int argc, char **argv)
 #else
        mc_debug("*** Media Controller Daemon is running [always] ***");
 #endif
+       __mc_main_create_daemon_launch_check_file();
 
        g_main_loop_run(g_mc_mainloop);
 
@@ -141,6 +157,8 @@ int main(int argc, char **argv)
 #endif
        mc_cynara_finish();
 
+       unlink(LAUNCH_CHECK_FILE);
+
        /* close socket */
        close(fd);
 
index d9317493f60a7c81bcf6ec52e6867546e97d3027..11d37c95bb0fa3b4df686c0acd0fbb4510688585 100644 (file)
@@ -23,6 +23,8 @@
 extern "C" {
 #endif /* __cplusplus */
 
+#define LAUNCH_CHECK_FILE              tzplatform_mkpath(TZ_SYS_TMP, "media_controller_launch")
+
 gpointer mc_svc_thread(void *data);
 GMainLoop *mc_svc_get_main_loop(void);
 int mc_svc_get_connection_cnt(void);
index 758f5772c5cdfcc3f373853bcc563282f0db8a00..3ca2942b97946711490af5403b2989e64d51f64b 100644 (file)
@@ -22,6 +22,7 @@
 #include "media_controller_private.h"
 #include "media_controller_db_util.h"
 #include "media_controller_socket.h"
+#include "media_controller_svc.h"
 
 int mc_ipc_create_client_socket(void)
 {
@@ -47,6 +48,9 @@ int mc_ipc_create_client_socket(void)
        if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
                mc_stderror("connect failed");
                close(sock);
+               if (access(LAUNCH_CHECK_FILE, F_OK) != 0)
+                       mc_error("media controller damon hasn't started yet. You have to wait. If daemon starts, [%s] file will be created.", LAUNCH_CHECK_FILE);
+
                return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
        }