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: Leandro Ribeiro <leandrohr@riseup.net>
dev
Leandro Ribeiro 5 years ago committed by Pekka Paalanen
parent 1ded661aac
commit 23491cd931
  1. 2
      libweston/weston-log-file.c
  2. 1
      libweston/weston-log-flight-rec.c
  3. 3
      libweston/weston-log-internal.h
  4. 15
      libweston/weston-log.c

@ -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()

Loading…
Cancel
Save