mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-27 06:46:44 -04:00
shm: we may exit with busy buffers remaining (seen on KDE)
This commit is contained in:
parent
99ea47c97a
commit
69260dd960
2 changed files with 22 additions and 8 deletions
2
render.c
2
render.c
|
|
@ -2311,7 +2311,7 @@ grid_render(struct terminal *term)
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (buf->age > 0) {
|
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 != NULL);
|
||||||
xassert(term->render.last_buf != buf);
|
xassert(term->render.last_buf != buf);
|
||||||
|
|
|
||||||
28
shm.c
28
shm.c
|
|
@ -151,13 +151,26 @@ buffer_destroy(struct buffer_private *buf)
|
||||||
void
|
void
|
||||||
shm_fini(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) {
|
tll_foreach(buffers, it) {
|
||||||
|
if (it->item.busy)
|
||||||
|
busy_count++;
|
||||||
|
else
|
||||||
|
non_busy_count++;
|
||||||
|
|
||||||
buffer_destroy(&it->item);
|
buffer_destroy(&it->item);
|
||||||
tll_remove(buffers, it);
|
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
|
#if defined(MEASURE_SHM_ALLOCS) && MEASURE_SHM_ALLOCS
|
||||||
LOG_INFO("max total allocations was: %zu MB", max_alloced / 1024 / 1024);
|
LOG_INFO("max total allocations was: %zu MB", max_alloced / 1024 / 1024);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -272,8 +285,9 @@ destroy_all_purgeables(void)
|
||||||
if (it->item.busy)
|
if (it->item.busy)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
LOG_DBG("cookie=%lx: purging buffer %p (width=%d, height=%d): %zu KB",
|
LOG_DBG("purging buffer %p (width=%d, height=%d): %zu KB",
|
||||||
cookie, (void *)&it->item, it->item.width, it->item.height,
|
(void *)&it->item,
|
||||||
|
it->item.public.width, it->item.public.height,
|
||||||
it->item.size / 1024);
|
it->item.size / 1024);
|
||||||
|
|
||||||
buffer_destroy(&it->item);
|
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->ref_count == 1);
|
||||||
xassert(pool->fd >= 0);
|
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;
|
const off_t diff = rows * buf->public.stride;
|
||||||
xassert(rows > 0);
|
xassert(rows > 0);
|
||||||
|
|
@ -865,9 +879,9 @@ shm_purge(struct wl_shm *shm, unsigned long cookie)
|
||||||
if (it->item.cookie != cookie)
|
if (it->item.cookie != cookie)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (it->item.busy) {
|
if (it->item.busy) {
|
||||||
LOG_WARN("deferring purge of 'busy' buffer (width=%d, height=%d)",
|
LOG_DBG("deferring purge of 'busy' buffer (width=%d, height=%d)",
|
||||||
it->item.public.width, it->item.public.height);
|
it->item.public.width, it->item.public.height);
|
||||||
it->item.purge = true;
|
it->item.purge = true;
|
||||||
} else {
|
} else {
|
||||||
buffer_destroy(&it->item);
|
buffer_destroy(&it->item);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue