mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
shm: close pool FD if buffer doesn’t support SHM scrolling
The only reason to keep the pool FD open is if we’re going to SHM scroll the buffer; we need the FD for fallocate(FALLOC_FL_PUNCH_HOLE). In all other cases, there’s absolutely no need to keep the FD open. Thus, close it as soon as we’ve instantiated the buffer. This frees up FDs, and help keep foot from FD ulimit.
This commit is contained in:
parent
a9872aac5a
commit
107cbb1015
1 changed files with 6 additions and 1 deletions
7
shm.c
7
shm.c
|
|
@ -156,7 +156,6 @@ page_size(void)
|
|||
static bool
|
||||
instantiate_offset(struct wl_shm *shm, struct buffer *buf, off_t new_offset)
|
||||
{
|
||||
xassert(buf->fd >= 0);
|
||||
xassert(buf->mmapped == NULL);
|
||||
xassert(buf->wl_buf == NULL);
|
||||
xassert(buf->pix == NULL);
|
||||
|
|
@ -417,6 +416,12 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie,
|
|||
}
|
||||
#endif
|
||||
|
||||
if (!shm_can_scroll(ret)) {
|
||||
/* We only need to keep the pool FD open if we’re going to SHM
|
||||
* scroll it */
|
||||
close(pool_fd);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
err:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue