Commit 23491cd9 authored by Leandro Ribeiro's avatar Leandro Ribeiro Committed by Pekka Paalanen

weston-log: destroy subscriptions with destruction of subscribers

The subscription is directly related to both the log scope and
the subscriber. It makes no sense to destroy one of them and
keep the subscriptions living.

We only had code to destroy subscription with
the destruction of log scopes. Add code to destroy
subscriptions with destruction of subscribers.
Signed-off-by: default avatarLeandro Ribeiro <leandrohr@riseup.net>
parent 1ded661a
......@@ -58,6 +58,8 @@ static void
weston_log_subscriber_destroy_log(struct weston_log_subscriber *subscriber)
{
struct weston_debug_log_file *file = to_weston_debug_log_file(subscriber);
weston_log_subscriber_release(subscriber);
free(file);
}
......
......@@ -228,6 +228,7 @@ weston_log_subscriber_destroy_flight_rec(struct weston_log_subscriber *sub)
if (weston_primary_flight_recorder_ring_buffer == &flight_rec->rb)
weston_primary_flight_recorder_ring_buffer = NULL;
weston_log_subscriber_release(sub);
free(flight_rec->rb.buf);
free(flight_rec);
}
......
......@@ -81,6 +81,9 @@ weston_log_subscription_add(struct weston_log_scope *scope,
void
weston_log_subscription_remove(struct weston_log_subscription *sub);
void
weston_log_subscriber_release(struct weston_log_subscriber *subscriber);
void
weston_log_bind_weston_debug(struct wl_client *client,
void *data, uint32_t version, uint32_t id);
......
......@@ -939,6 +939,21 @@ weston_log_scope_timestamp(struct weston_log_scope *scope,
return buf;
}
void
weston_log_subscriber_release(struct weston_log_subscriber *subscriber)
{
struct weston_log_subscription *sub, *sub_tmp;
wl_list_for_each_safe(sub, sub_tmp, &subscriber->subscription_list, owner_link) {
/* destroy each subscription */
if (sub->owner->destroy_subscription)
sub->owner->destroy_subscription(sub->owner);
weston_log_subscription_destroy(sub);
}
}
/** Destroy a file type or a flight-rec type subscriber.
*
* They are created, respectively, with weston_log_subscriber_create_log()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment