mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
llvmpipe: handle os_dupfd_cloexec failure
Make it easy to debug fd leak or hitting open fd limit. Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38074>
This commit is contained in:
parent
1be7832f3e
commit
4d0fbd1c67
2 changed files with 24 additions and 2 deletions
|
|
@ -294,10 +294,15 @@ lp_create_fence_fd(struct pipe_context *pipe,
|
|||
if (!f)
|
||||
goto fail;
|
||||
|
||||
f->sync_fd = os_dupfd_cloexec(fd);
|
||||
if (f->sync_fd < 0) {
|
||||
free(f);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pipe_reference_init(&f->reference, 1);
|
||||
f->type = LP_FENCE_TYPE_SYNC_FD;
|
||||
f->id = p_atomic_inc_return(&fence_id) - 1;
|
||||
f->sync_fd = os_dupfd_cloexec(fd);
|
||||
f->issued = true;
|
||||
|
||||
*fence = (struct pipe_fence_handle*)f;
|
||||
|
|
|
|||
|
|
@ -852,7 +852,10 @@ llvmpipe_resource_get_handle(struct pipe_screen *_screen,
|
|||
/* reuse lavapipe codepath to handle destruction */
|
||||
lpr->backable = true;
|
||||
} else {
|
||||
assert(lpr->dmabuf_alloc->fd >= 0);
|
||||
whandle->handle = os_dupfd_cloexec(lpr->dmabuf_alloc->fd);
|
||||
if (whandle->handle < 0)
|
||||
return false;
|
||||
}
|
||||
whandle->modifier = DRM_FORMAT_MOD_LINEAR;
|
||||
whandle->stride = lpr->row_stride[0];
|
||||
|
|
@ -1460,8 +1463,15 @@ llvmpipe_allocate_memory_fd(struct pipe_screen *pscreen,
|
|||
alloc->type = LLVMPIPE_MEMORY_FD_TYPE_DMA_BUF;
|
||||
alloc->cpu_addr = llvmpipe_resource_alloc_udmabuf(screen, alloc, size);
|
||||
|
||||
if (alloc->cpu_addr)
|
||||
if (alloc->cpu_addr) {
|
||||
*fd = os_dupfd_cloexec(alloc->fd);
|
||||
if (*fd < 0) {
|
||||
close(alloc->mem_fd);
|
||||
close(alloc->fd);
|
||||
FREE(alloc);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
|
@ -1517,6 +1527,13 @@ llvmpipe_import_memory_fd(struct pipe_screen *screen,
|
|||
alloc->cpu_addr = cpu_addr;
|
||||
alloc->size = mmap_size;
|
||||
alloc->fd = os_dupfd_cloexec(fd);
|
||||
if (alloc->fd < 0) {
|
||||
munmap(alloc->cpu_addr, alloc->size);
|
||||
free(alloc);
|
||||
*ptr = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
*ptr = (struct pipe_memory_allocation*)alloc;
|
||||
*size = mmap_size;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue