From 8fc4b59bfdd99b9916da523a6358232beb2ba829 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 13 Dec 2019 11:47:18 +0200 Subject: [PATCH] weston-log-flight-rec: allow re-running a compositor weston_primary_flight_recorder_ring_buffer needs to be cleared on destruction of the subscriber it was assigned from so that a compositor and be re-executed in-process (static variables do not get re-initialized automatically). This will be used by the test harness when it will execute wet_main() multiple times in the same process. Otherwise it would hit the assert in weston_log_subscriber_create_flight_rec(). Signed-off-by: Pekka Paalanen --- libweston/weston-log-flight-rec.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libweston/weston-log-flight-rec.c b/libweston/weston-log-flight-rec.c index 31ea3045..16d18a90 100644 --- a/libweston/weston-log-flight-rec.c +++ b/libweston/weston-log-flight-rec.c @@ -265,11 +265,18 @@ weston_log_subscriber_create_flight_rec(size_t size) * * @param sub the weston_log_subscriber object * + * This also resets weston_primary_flight_recorder_ring_buffer to NULL if it + * is the destroyed subscriber. */ WL_EXPORT void weston_log_subscriber_destroy_flight_rec(struct weston_log_subscriber *sub) { - struct weston_debug_log_flight_recorder *flight_rec = to_flight_recorder(sub); + struct weston_debug_log_flight_recorder *flight_rec; + + flight_rec = to_flight_recorder(sub); + if (weston_primary_flight_recorder_ring_buffer == &flight_rec->rb) + weston_primary_flight_recorder_ring_buffer = NULL; + free(flight_rec->rb.buf); free(flight_rec); }