Add to detect stdin close 01/300401/4 accepted/tizen/unified/20231030.034754
authorYoungHun Kim <yh8004.kim@samsung.com>
Tue, 24 Oct 2023 01:19:04 +0000 (10:19 +0900)
committerYoungHun Kim <yh8004.kim@samsung.com>
Wed, 25 Oct 2023 22:37:24 +0000 (07:37 +0900)
 - There is issue of accept() 0 after idle, which means stdin is already closed as below.
    muse_server_private.c: _ms_check_idle_state(523) > [#3] 2707s [period 900s] [0d 10h 8m 56s]
    ...
    _ms_connection_handler(376) > Critical Error : accept 0 is invalid

   So I add to check periodically the status during idle and after destroy() to debug issue.

Change-Id: I866e638c9a9a98b74fdad58f963c7cb39c14b7ed

packaging/mused.spec
server/include/muse_server_private.h
server/src/muse_server_ipc.c
server/src/muse_server_private.c

index f45ba8d..3540be5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mused
 Summary:    A multimedia daemon
-Version:    0.3.175
+Version:    0.3.176
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index b4ea7cf..b59070e 100644 (file)
@@ -123,6 +123,7 @@ gboolean ms_check_module_idx(int idx);
 ms_module_t *ms_get_module_instance(int idx);
 int ms_deinit(void);
 void ms_check_cpu_memory(void);
+void ms_check_stdin_close(void);
 void ms_new(void);
 void ms_run(void);
 void ms_cmd_dispatch(muse_module_h m, muse_module_command_e cmd);
index fcc0868..ae9a75e 100644 (file)
@@ -111,6 +111,8 @@ static void _ms_ipc_module_cleanup(muse_module_h m)
 
        LOGI("[module %p] EXIT pid %d handle %zd created %d", m, m->pid, m->handle, m->is_created);
        g_free(m);
+
+       ms_check_stdin_close();
 }
 
 static gboolean _ms_ipc_module_instance_creation_is_allowed(int module_idx)
index 48a036f..889118e 100644 (file)
@@ -545,6 +545,7 @@ static gpointer _ms_diag_check_idle_state_thread(gpointer data)
 
        while (ms_is_server_ready()) {
                _ms_check_idle_state();
+               ms_check_stdin_close();
                sleep(idle_state_wait_time);
        }
 
@@ -1270,6 +1271,19 @@ void ms_check_cpu_memory(void)
        ms_connection_unlock(connection);
 }
 
+void ms_check_stdin_close(void)
+{
+       ms_connection_t *connection = muse_server->connection;
+       muse_return_if_fail(connection);
+
+       ms_connection_lock(connection);
+
+       if (fcntl(STDIN_FILENO, F_GETFD) == -1 && errno == EBADF)
+               LOGE("stdin is closed.");
+
+       ms_connection_unlock(connection);
+}
+
 void ms_new(void)
 {
        int fd[MUSE_CHANNEL_MAX];