diff --git a/libweston/weston-log-internal.h b/libweston/weston-log-internal.h index 02a05f19..f1bfa6a5 100644 --- a/libweston/weston-log-internal.h +++ b/libweston/weston-log-internal.h @@ -72,9 +72,6 @@ weston_log_subscription_create(struct weston_log_subscriber *owner, void weston_log_subscription_destroy(struct weston_log_subscription *sub); -struct weston_log_subscription * -weston_log_subscriber_get_only_subscription(struct weston_log_subscriber *subscriber); - void weston_log_subscription_add(struct weston_log_scope *scope, struct weston_log_subscription *sub); diff --git a/libweston/weston-log-wayland.c b/libweston/weston-log-wayland.c index 732439f2..0add7728 100644 --- a/libweston/weston-log-wayland.c +++ b/libweston/weston-log-wayland.c @@ -162,7 +162,9 @@ static void weston_log_debug_wayland_to_destroy(struct weston_log_subscriber *sub) { struct weston_log_debug_wayland *stream = to_weston_log_debug_wayland(sub); - stream_close_on_failure(stream, "debug name removed"); + + if (stream->fd != -1) + stream_close_on_failure(stream, "debug name removed"); } static struct weston_log_debug_wayland * @@ -201,20 +203,10 @@ static void stream_destroy(struct wl_resource *stream_resource) { struct weston_log_debug_wayland *stream; - struct weston_log_subscription *sub = NULL; - stream = wl_resource_get_user_data(stream_resource); - if (stream->fd != -1) - close(stream->fd); - - sub = weston_log_subscriber_get_only_subscription(&stream->base); - - /* we can have a zero subscription if clients tried to subscribe - * to a non-existent scope */ - if (sub) - weston_log_subscription_destroy(sub); - + stream_close_unlink(stream); + weston_log_subscriber_release(&stream->base); free(stream); } diff --git a/libweston/weston-log.c b/libweston/weston-log.c index 7d85a6be..b6f46c31 100644 --- a/libweston/weston-log.c +++ b/libweston/weston-log.c @@ -293,30 +293,6 @@ weston_log_subscription_destroy(struct weston_log_subscription *sub) free(sub); } -/** Retrieve a subscription by using the subscriber - * - * This is useful when trying to find a subscription from the subscriber by - * having only access to the stream. - * - * @param subscriber the subscriber in question - * @returns a weston_log_subscription object - * - * @memberof weston_log_subscription - */ -struct weston_log_subscription * -weston_log_subscriber_get_only_subscription(struct weston_log_subscriber *subscriber) -{ - struct weston_log_subscription *sub; - /* unlikely, but can happen */ - if (wl_list_length(&subscriber->subscription_list) == 0) - return NULL; - - assert(wl_list_length(&subscriber->subscription_list) == 1); - - return wl_container_of(subscriber->subscription_list.prev, - sub, owner_link); -} - /** Adds the subscription \c sub to the subscription list of the * scope. *