blob: 7049f561d2d587afdca1d5081922a581133843d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
diff ... libdrm-2.4.73/intel/intel_bufmgr_gem.c
--- libdrm-2.4.73-ref/intel/intel_bufmgr_gem.c Mon Nov 14 14:48:04 2016
+++ libdrm-2.4.73/intel/intel_bufmgr_gem.c Mon Nov 28 14:37:11 2016
@@ -3352,6 +3352,16 @@
static pthread_mutex_t bufmgr_list_mutex = PTHREAD_MUTEX_INITIALIZER;
static drmMMListHead bufmgr_list = { &bufmgr_list, &bufmgr_list };
+static int
+compare_file_descriptor(int fd1, int fd2) {
+ struct stat stat1, stat2;
+ if (fstat (fd1, &stat1) < 0)
+ return -1;
+ if (fstat (fd2, &stat2) < 0)
+ return -1;
+ return (stat1.st_dev == stat2.st_dev) && (stat1.st_ino == stat2.st_ino);
+}
+
static drm_intel_bufmgr_gem *
drm_intel_bufmgr_gem_find(int fd)
{
@@ -3358,7 +3368,8 @@
drm_intel_bufmgr_gem *bufmgr_gem;
DRMLISTFOREACHENTRY(bufmgr_gem, &bufmgr_list, managers) {
- if (bufmgr_gem->fd == fd) {
+ if (bufmgr_gem->fd == fd ||
+ compare_file_descriptor (bufmgr_gem->fd, fd)) {
atomic_inc(&bufmgr_gem->refcount);
return bufmgr_gem;
}
|