summaryrefslogtreecommitdiff
path: root/miext/sync
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-11-21 22:12:34 -0800
committerKeith Packard <keithp@keithp.com>2013-12-02 12:57:08 -0800
commitb6d7ed4d787a652e8150532f384bfdf51760f3c2 (patch)
tree8d7bf4b1a92ecccefe2a0aa2832108967a700627 /miext/sync
parentcc63204926c6da83d9221c5f8c0dc8f5e2f2481d (diff)
miext: Move SyncShm FDs out of the way of clients
Applications may end up allocating a bunch of shmfence objects, each of which uses a file descriptor, which must be kept open lest some other client ask for a copy of it later on. Lacking an API that can turn a memory mapping back into a file descriptor, about the best we can do is push the file descriptors out of the way of other X clients so that we don't run out of the ability to accept new connections. This uses fcntl F_GETFD to push the FD up above MAXCLIENTS. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Julien Cristau <jcristau@debian.org>
Diffstat (limited to 'miext/sync')
-rw-r--r--miext/sync/misyncshm.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/miext/sync/misyncshm.c b/miext/sync/misyncshm.c
index 3f9350af5..20780fde8 100644
--- a/miext/sync/misyncshm.c
+++ b/miext/sync/misyncshm.c
@@ -32,6 +32,7 @@
#include "pixmapstr.h"
#include <sys/mman.h>
#include <unistd.h>
+#include <fcntl.h>
#include <X11/xshmfence.h>
static DevPrivateKeyRec syncShmFencePrivateKey;
@@ -126,6 +127,7 @@ miSyncShmCreateFenceFromFd(ScreenPtr pScreen, SyncFence *pFence, int fd, Bool in
miSyncInitFence(pScreen, pFence, initially_triggered);
+ fd = os_move_fd(fd);
pPriv->fence = xshmfence_map_shm(fd);
if (pPriv->fence) {
pPriv->fd = fd;
@@ -145,6 +147,7 @@ miSyncShmGetFenceFd(ScreenPtr pScreen, SyncFence *pFence)
pPriv->fd = xshmfence_alloc_shm();
if (pPriv->fd < 0)
return -1;
+ pPriv->fd = os_move_fd(pPriv->fd);
pPriv->fence = xshmfence_map_shm(pPriv->fd);
if (!pPriv->fence) {
close (pPriv->fd);