From c17091b79773e9c458f03a897b26c2257d7366a7 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Mon, 22 Sep 2014 18:05:19 +0200 Subject: terminal: signal object removal during sysview_context_stop() Now that we no longer propagate callback return values, we can safely call into user-callbacks during sysview_context_stop(). This way, users can rely on all objects to be removed via callbacks (except if they failed during object creation). This avoids duplicating any object hashtables on the users' side and reduces memory consumption. --- src/libsystemd-terminal/sysview.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/libsystemd-terminal/sysview.c') diff --git a/src/libsystemd-terminal/sysview.c b/src/libsystemd-terminal/sysview.c index 969514ad9d..cd776f62d8 100644 --- a/src/libsystemd-terminal/sysview.c +++ b/src/libsystemd-terminal/sysview.c @@ -1437,20 +1437,6 @@ void sysview_context_stop(sysview_context *c) { log_debug("sysview: stop"); - c->running = false; - c->scanned = false; - c->event_fn = NULL; - c->userdata = NULL; - c->scan_src = sd_event_source_unref(c->scan_src); - context_ud_stop(c); - context_ld_stop(c); - - /* - * Event-callbacks are already cleared, hence we can safely ignore - * return codes of the context_remove_*() helpers. They cannot be - * originated from user-callbacks, so we already handled them. - */ - while ((device = hashmap_first(c->device_map))) context_remove_device(c, device); @@ -1459,6 +1445,14 @@ void sysview_context_stop(sysview_context *c) { while ((seat = hashmap_first(c->seat_map))) context_remove_seat(c, seat); + + c->running = false; + c->scanned = false; + c->event_fn = NULL; + c->userdata = NULL; + c->scan_src = sd_event_source_unref(c->scan_src); + context_ud_stop(c); + context_ld_stop(c); } static int context_scan_fn(sd_event_source *s, void *userdata) { -- cgit v1.2.3-54-g00ecf