daemon: Exit when a client does not exist
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 23 May 2023 01:20:59 +0000 (10:20 +0900)
committer이상철/Tizen Platform Lab(SR)/삼성전자 <sc11.lee@samsung.com>
Wed, 24 May 2023 01:36:23 +0000 (10:36 +0900)
It is only for USE_SERVICE_APP.

The default value of socket path in meson_options.txt is also fixed.

[Version] 0.3.1

Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
meson_options.txt
packaging/espp-service.spec
src/daemon/espp_service_socket.c

index db5fd736d4a83002f89ab81a1e7f42ee4123ecc2..f69c4a07a8d2866ef4f921ac40af38c9af51269a 100644 (file)
@@ -1,4 +1,4 @@
-option('version', type: 'string', value: '0.0.0', description: 'ESPP service version')
-option('sock-path', type: 'string', value: '/tmp/espp_service.socket', description: 'ESPP service socket path')
+option('version', type: 'string', value: '0.3.1', description: 'ESPP service version')
+option('sock-path', type: 'string', value: '/tmp/espp_service.sock', description: 'ESPP service socket path')
 option('dlog', type: 'boolean', value: true, description: 'Use dlog')
 option('service-app', type: 'boolean', value: false, description: 'Daemon is launched as Tizen service app')
index 778c0d885e0b780784681b95812a7998fc899823..6c91944de168c5f2b26787a02b60548a91ddef19 100644 (file)
@@ -1,6 +1,6 @@
 Name:       espp-service
 Summary:    ESPP service package which contains client lib. and daemon binary
-Version:    0.3.0
+Version:    0.3.1
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 691f38edefb852fe8ef2b64844e477c451570a7b..7e448cc7d7c2ae94e3c4ea00da52fd903a1e5033 100644 (file)
@@ -20,6 +20,9 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <pthread.h>
+#ifdef USE_SERVICE_APP
+#include <service_app.h>
+#endif
 
 #define EXIT_IF_NEEDED(x_rx_data) \
 do { \
@@ -125,10 +128,14 @@ static void *__work_thread_func(void *data)
 {
        bool event_mode = false;
        handler_userdata_s *hdata = (handler_userdata_s *)data;
+       espp_service_s *svc;
+       guint num_of_clients;
 
        ASSERT(hdata);
        ASSERT(hdata->fd != -1);
 
+       svc = hdata->svc;
+
        LOG_WARNING("entrance, fd[%d]", hdata->fd);
 
        while (1) {
@@ -142,9 +149,16 @@ static void *__work_thread_func(void *data)
        }
 
 exit:
-       LOG_WARNING("exit, fd[%d]", hdata->fd);
+       num_of_clients = g_hash_table_size(hdata->svc->fd_table);
+       LOG_WARNING("exit, fd[%d], svc[%p], num_of_clients[%u] remain", hdata->fd, svc, num_of_clients);
        close(hdata->fd);
        g_free(hdata);
+#ifdef USE_SERVICE_APP
+       if (num_of_clients == 0) {
+               LOG_ERROR("no more clients, service exits now...");
+               service_app_exit();
+       }
+#endif
        pthread_exit(NULL);
 }