From: Changgyu Choi Date: Mon, 16 Oct 2023 08:30:38 +0000 (+0900) Subject: Use global mutex variable on __send_result() X-Git-Tag: accepted/tizen/unified/20231018.120756~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=397ee064445937474ed21c9767e5d2e673e901fc;p=platform%2Fcore%2Fappfw%2Faul-1.git Use global mutex variable on __send_result() The socket io of aul+ require mutex because read and write can occur at the same time. This patch uses the global mutex instead of the previously removed channel mutex. Change-Id: I7189dc4567c2a0150e40877b67f42baf62719b4a Signed-off-by: Changgyu Choi --- diff --git a/src/aul_launch.c b/src/aul_launch.c index b4a555c..e09b9d2 100644 --- a/src/aul_launch.c +++ b/src/aul_launch.c @@ -49,7 +49,6 @@ typedef struct client_channel_s { int fd; pid_t pid; uid_t uid; - GRecMutex mutex; } client_channel_t; struct aul_request_s { @@ -108,11 +107,6 @@ AUL_DTOR static void __aul_destructor(void) static void __destroy_client_channel(gpointer data) { client_channel_t *channel = data; - - g_rec_mutex_lock(&channel->mutex); - g_rec_mutex_unlock(&channel->mutex); - g_rec_mutex_clear(&channel->mutex); - free(channel); } @@ -126,8 +120,6 @@ static client_channel_t *__create_client_channel(int fd, pid_t pid, uid_t uid) return NULL; } - g_rec_mutex_init(&channel->mutex); - channel->fd = fd; channel->pid = pid; channel->uid = uid; @@ -404,10 +396,12 @@ static int __send_result(struct aul_request_s *req, int res) int ret; if (req->cmd != WIDGET_GET_CONTENT && req->clifd >= 0) { + g_rec_mutex_lock(&__context.mutex); if (__find_client_channel(req->clifd) == NULL) _E("Failed to find client channel. fd(%d)", req->clifd); ret = aul_sock_send_result_v2(req->clifd, res, false); + g_rec_mutex_unlock(&__context.mutex); if (ret < 0) { _E("Failed to send result. cmd(%s:%d)", aul_cmd_convert_to_string(req->cmd), @@ -541,9 +535,11 @@ static bool __received_event_cb(int fd, int condition, void *user_data) app_pkt_t *pkt; int ret; + g_rec_mutex_lock(&__context.mutex); channel = __find_client_channel(fd); if (!channel) { _E("Failed to find client channel. fd(%d)", fd); + g_rec_mutex_unlock(&__context.mutex); return false; } @@ -552,12 +548,12 @@ static bool __received_event_cb(int fd, int condition, void *user_data) aul_worker_remove_io_job(worker, fd); __remove_client_channel(channel); __destroy_client_channel(channel); + g_rec_mutex_unlock(&__context.mutex); return true; } - g_rec_mutex_lock(&channel->mutex); ret = aul_sock_recv_reply_pkt_v2(fd, &pkt, false); - g_rec_mutex_unlock(&channel->mutex); + g_rec_mutex_unlock(&__context.mutex); if (ret != 0) { _E("Failed to receive the packet. error(%d)", ret); return true;