summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossymiles@gmail.com>2014-12-11 23:20:35 +1100
committerJames Ross-Gowan <rossymiles@gmail.com>2014-12-11 23:38:15 +1100
commit8a270250e800498ce168d2b3b097d2f6acf13dd8 (patch)
tree734cf0580ff8917cd61e30a0bff0f76971a675c7
parentd01cf36c746de672afc123652b7b2033a9403b3d (diff)
downloadmpv-8a270250e800498ce168d2b3b097d2f6acf13dd8.tar.bz2
mpv-8a270250e800498ce168d2b3b097d2f6acf13dd8.tar.xz
pipe-win32: possible fix for Windows XP deadlock
This fixes a hang with the VirtualBox OpenGL drivers. It might help with #1325 as well.
-rw-r--r--input/pipe-win32.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/input/pipe-win32.c b/input/pipe-win32.c
index 816bdcffed..4077ea84ee 100644
--- a/input/pipe-win32.c
+++ b/input/pipe-win32.c
@@ -45,6 +45,16 @@ static void read_pipe_thread(struct mp_input_src *src, void *param)
goto done;
}
+ // If we're reading from stdin, unset it. All I/O on synchronous handles is
+ // serialized, so stupid DLLs that call GetFileType on stdin can hang the
+ // process if they do it while we're reading from it. At least, the
+ // VirtualBox OpenGL ICD is affected by this, but only on Windows XP.
+ // GetFileType works differently in later versions of Windows. See:
+ // https://support.microsoft.com/kb/2009703
+ // http://blogs.msdn.com/b/oldnewthing/archive/2011/12/02/10243553.aspx
+ if ((void*)_get_osfhandle(fd) == GetStdHandle(STD_INPUT_HANDLE))
+ SetStdHandle(STD_INPUT_HANDLE, NULL);
+
waio = waio_alloc((void *)_get_osfhandle(fd), 0, NULL, NULL);
if (!waio) {
MP_ERR(src, "Can't initialize win32 file reader.\n");