aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-07-16 14:47:15 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-07-17 17:14:41 +0000
commit69260dd9604f39f5e7270ac44502c7e60618500b (patch)
tree124d4c70a513fe1ee98042f208342d78987ddcc7
parentshm: move ‘size’ to the private buffer struct (diff)
shm: we may exit with busy buffers remaining (seen on KDE)
-rw-r--r--render.c2
-rw-r--r--shm.c28
2 files changed, 22 insertions, 8 deletions
diff --git a/render.c b/render.c
index c48c515a..90fdae7b 100644
--- a/render.c
+++ b/render.c
@@ -2311,7 +2311,7 @@ grid_render(struct terminal *term)
}
else if (buf->age > 0) {
- LOG_DBG("buffer age: %u", buf->age);
+ LOG_DBG("buffer age: %u (%p)", buf->age, (void *)buf);
xassert(term->render.last_buf != NULL);
xassert(term->render.last_buf != buf);
diff --git a/shm.c b/shm.c
index cd26c62e..87900f01 100644
--- a/shm.c
+++ b/shm.c
@@ -151,13 +151,26 @@ buffer_destroy(struct buffer_private *buf)
void
shm_fini(void)
{
- xassert(tll_length(buffers) == 0);
+ size_t busy_count UNUSED = 0;
+ size_t non_busy_count UNUSED = 0;
tll_foreach(buffers, it) {
+ if (it->item.busy)
+ busy_count++;
+ else
+ non_busy_count++;
+
buffer_destroy(&it->item);
tll_remove(buffers, it);
}
+ LOG_DBG("buffers left: busy=%zu, non-busy=%zu", busy_count, non_busy_count);
+
+ if (non_busy_count > 0) {
+ BUG("%zu non-busy buffers remaining (%zu buffers in total)",
+ non_busy_count, busy_count + non_busy_count);
+ }
+
#if defined(MEASURE_SHM_ALLOCS) && MEASURE_SHM_ALLOCS
LOG_INFO("max total allocations was: %zu MB", max_alloced / 1024 / 1024);
#endif
@@ -272,8 +285,9 @@ destroy_all_purgeables(void)
if (it->item.busy)
continue;
- LOG_DBG("cookie=%lx: purging buffer %p (width=%d, height=%d): %zu KB",
- cookie, (void *)&it->item, it->item.width, it->item.height,
+ LOG_DBG("purging buffer %p (width=%d, height=%d): %zu KB",
+ (void *)&it->item,
+ it->item.public.width, it->item.public.height,
it->item.size / 1024);
buffer_destroy(&it->item);
@@ -630,7 +644,7 @@ shm_scroll_forward(struct wl_shm *shm, struct buffer_private *buf, int rows,
xassert(pool->ref_count == 1);
xassert(pool->fd >= 0);
- LOG_DBG("scrolling %d rows (%d bytes)", rows, rows * buf->stride);
+ LOG_DBG("scrolling %d rows (%d bytes)", rows, rows * buf->public.stride);
const off_t diff = rows * buf->public.stride;
xassert(rows > 0);
@@ -865,9 +879,9 @@ shm_purge(struct wl_shm *shm, unsigned long cookie)
if (it->item.cookie != cookie)
continue;
- if (it->item.busy) {
- LOG_WARN("deferring purge of 'busy' buffer (width=%d, height=%d)",
- it->item.public.width, it->item.public.height);
+ if (it->item.busy) {
+ LOG_DBG("deferring purge of 'busy' buffer (width=%d, height=%d)",
+ it->item.public.width, it->item.public.height);
it->item.purge = true;
} else {
buffer_destroy(&it->item);