Force close clipboard files
authorakallabeth <akallabeth@posteo.net>
Fri, 26 Mar 2021 10:21:27 +0000 (11:21 +0100)
committerakallabeth <akallabeth@users.noreply.github.com>
Tue, 25 May 2021 13:30:50 +0000 (15:30 +0200)
(cherry picked from commit 781c764dfda8876a8b49288c2fef01cfe1173a7f)

winpr/libwinpr/clipboard/posix.c

index 540815e..b278491 100644 (file)
@@ -835,7 +835,9 @@ UINT posix_file_read_close(struct posix_file* file, BOOL force)
        if (file->fd < 0)
                return NO_ERROR;
 
-       if ((file->offset >= file->size) || force)
+       /* Always force close the file. Clipboard might open hundreds of files
+        * so avoid caching to prevent running out of available file descriptors */
+       if ((file->offset >= file->size) || force || TRUE)
        {
                WLog_VRB(TAG, "close file %d", file->fd);