virgl: use os_dupfd_cloexec from mesa util

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
macos/master
Yiwei Zhang 3 years ago
parent ba30df1bdc
commit 3a7c0bf6de
  1. 9
      src/virgl_resource.c

@ -30,6 +30,7 @@
#include <string.h>
#include <unistd.h>
#include "util/os_file.h"
#include "util/u_hash_table.h"
#include "util/u_pointer.h"
#include "virgl_util.h"
@ -219,13 +220,7 @@ enum virgl_resource_fd_type
virgl_resource_export_fd(struct virgl_resource *res, int *fd)
{
if (res->fd_type != VIRGL_RESOURCE_FD_INVALID) {
#ifdef F_DUPFD_CLOEXEC
*fd = fcntl(res->fd, F_DUPFD_CLOEXEC, 0);
if (*fd < 0)
*fd = dup(res->fd);
#else
*fd = dup(res->fd);
#endif
*fd = os_dupfd_cloexec(res->fd);
return *fd >= 0 ? res->fd_type : VIRGL_RESOURCE_FD_INVALID;
} else if (res->pipe_resource) {
return pipe_callbacks.export_fd(res->pipe_resource,

Loading…
Cancel
Save