|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From c17091b79773e9c458f03a897b26c2257d7366a7 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: David Herrmann <dh.herrmann@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Mon, 22 Sep 2014 18:05:19 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] terminal: signal object removal during sysview_context_stop()
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Now that we no longer propagate callback return values, we can safely call
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
into user-callbacks during sysview_context_stop(). This way, users can
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
rely on all objects to be removed via callbacks (except if they failed
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
during object creation). This avoids duplicating any object hashtables on
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
the users' side and reduces memory consumption.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/evcat.c | 3 ++-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/modeset.c | 3 ++-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/sysview.c | 22 ++++++++--------------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
3 files changed, 12 insertions(+), 16 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/evcat.c b/src/libsystemd-terminal/evcat.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index b3f08e60bf..62556f6a2b 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/evcat.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/evcat.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -330,7 +330,8 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
case SYSVIEW_EVENT_SESSION_REMOVE:
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
idev_session_disable(e->idev_session);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
e->idev_session = idev_session_free(e->idev_session);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- sd_event_exit(e->event, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (sd_event_get_exit_code(e->event, &r) == -ENODATA)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ sd_event_exit(e->event, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
break;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
case SYSVIEW_EVENT_SESSION_ATTACH:
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
d = ev->session_attach.device;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/modeset.c b/src/libsystemd-terminal/modeset.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 7a28e7ab97..f564fa0f65 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/modeset.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/modeset.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -332,7 +332,8 @@ static int modeset_sysview_fn(sysview_context *c, void *userdata, sysview_event
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
grdev_session_restore(m->grdev_session);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
grdev_session_disable(m->grdev_session);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
m->grdev_session = grdev_session_free(m->grdev_session);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- sd_event_exit(m->event, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (sd_event_get_exit_code(m->event, &r) == -ENODATA)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ sd_event_exit(m->event, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
break;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
case SYSVIEW_EVENT_SESSION_ATTACH:
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
d = ev->session_attach.device;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/sysview.c b/src/libsystemd-terminal/sysview.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 969514ad9d..cd776f62d8 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/sysview.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/sysview.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1437,20 +1437,6 @@ void sysview_context_stop(sysview_context *c) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_debug("sysview: stop");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- c->running = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- c->scanned = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- c->event_fn = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- c->userdata = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- c->scan_src = sd_event_source_unref(c->scan_src);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- context_ud_stop(c);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- context_ld_stop(c);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- /*
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * Event-callbacks are already cleared, hence we can safely ignore
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * return codes of the context_remove_*() helpers. They cannot be
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * originated from user-callbacks, so we already handled them.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
while ((device = hashmap_first(c->device_map)))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
context_remove_device(c, device);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1459,6 +1445,14 @@ void sysview_context_stop(sysview_context *c) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
while ((seat = hashmap_first(c->seat_map)))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
context_remove_seat(c, seat);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ c->running = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ c->scanned = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ c->event_fn = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ c->userdata = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ c->scan_src = sd_event_source_unref(c->scan_src);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ context_ud_stop(c);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ context_ld_stop(c);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static int context_scan_fn(sd_event_source *s, void *userdata) {
|