From: Seunghun Lee Date: Thu, 2 May 2024 06:16:36 +0000 (+0900) Subject: server: Unlock objects_mutex before locking connection_mutex to avoid deadlock X-Git-Tag: accepted/tizen/unified/x/20240507.050949 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2Faccepted%2Ftizen%2Funified%2Fx%2F20240507.050949;p=platform%2Fupstream%2Fwayland.git server: Unlock objects_mutex before locking connection_mutex to avoid deadlock In wl_client_connection_data, threads may try to acquire two locks in different orders, potentially causing deadlock. Change-Id: I4acde7c0a93b4774632d3283a6fa1c946d498de8 --- diff --git a/src/wayland-server.c b/src/wayland-server.c index 2106451..eca5f1e 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -2222,15 +2222,15 @@ wl_resource_create(struct wl_client *client, pthread_mutex_lock(&client->objects_mutex); //TIZEN_ONLY : END if (wl_map_insert_at(&client->objects, 0, id, resource) < 0) { +//TIZEN_ONLY(20231208) : Add lock/unlock when adding resource id to wl_map + pthread_mutex_unlock(&client->objects_mutex); +//TIZEN_ONLY : END if (errno == EINVAL) { wl_resource_post_error(client->display_resource, WL_DISPLAY_ERROR_INVALID_OBJECT, "invalid new id %d", id); } free(resource); -//TIZEN_ONLY(20231208) : Add lock/unlock when adding resource id to wl_map - pthread_mutex_unlock(&client->objects_mutex); -//TIZEN_ONLY : END return NULL; } //TIZEN_ONLY(20231208) : Add lock/unlock when adding resource id to wl_map @@ -2716,15 +2716,15 @@ wl_client_add_resource(struct wl_client *client, } } else if (wl_map_insert_at(&client->objects, WL_MAP_ENTRY_LEGACY, resource->object.id, resource) < 0) { +//TIZEN_ONLY(20231208) : Add lock/unlock when adding resource id to wl_map + pthread_mutex_unlock(&client->objects_mutex); +//TIZEN_ONLY : END if (errno == EINVAL) { wl_resource_post_error(client->display_resource, WL_DISPLAY_ERROR_INVALID_OBJECT, "invalid new id %d", resource->object.id); } -//TIZEN_ONLY(20231208) : Add lock/unlock when adding resource id to wl_map - pthread_mutex_unlock(&client->objects_mutex); -//TIZEN_ONLY : END return 0; } //TIZEN_ONLY(20231208) : Add lock/unlock when adding resource id to wl_map