mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-12 16:35:58 +01:00
backend/drm: dup FD before wlr_gbm_allocator_create
The GBM allocator takes ownership of the DRM FD.
This commit is contained in:
parent
3fd8098881
commit
1ca4d6b029
1 changed files with 10 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <assert.h>
|
||||
#include <drm_fourcc.h>
|
||||
#include <fcntl.h>
|
||||
#include <gbm.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -37,9 +39,16 @@ bool init_drm_renderer(struct wlr_drm_backend *drm,
|
|||
goto error_gbm;
|
||||
}
|
||||
|
||||
renderer->allocator = wlr_gbm_allocator_create(drm->fd);
|
||||
int alloc_fd = fcntl(drm->fd, F_DUPFD_CLOEXEC, 0);
|
||||
if (alloc_fd < 0) {
|
||||
wlr_log_errno(WLR_ERROR, "fcntl(F_DUPFD_CLOEXEC) failed");
|
||||
goto error_wlr_rend;
|
||||
}
|
||||
|
||||
renderer->allocator = wlr_gbm_allocator_create(alloc_fd);
|
||||
if (renderer->allocator == NULL) {
|
||||
wlr_log(WLR_ERROR, "Failed to create allocator");
|
||||
close(alloc_fd);
|
||||
goto error_wlr_rend;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue