summaryrefslogtreecommitdiffstats
path: root/player/lua.c
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossymiles@gmail.com>2014-11-19 15:46:20 +1100
committerJames Ross-Gowan <rossymiles@gmail.com>2014-11-22 18:15:08 +1100
commitf2b94a3b499667cefe848ecc57487c8fe62584f4 (patch)
tree936d07833308672c25f6f6d970f2ca50a2dcb855 /player/lua.c
parent92316eb7406b27f4c1bd353b8f242c7ff28d64f5 (diff)
downloadmpv-f2b94a3b499667cefe848ecc57487c8fe62584f4.tar.bz2
mpv-f2b94a3b499667cefe848ecc57487c8fe62584f4.tar.xz
lua: subprocess: cancel pending I/O before return
I'm not sure if this is necessary, but it can't hurt, and it's what you're supposed to do before leaving the stack frame that contains the OVERLAPPED object and the buffer. If there is no pending I/O, CancelIo will do nothing and GetOverlappedResult will silently fail.
Diffstat (limited to 'player/lua.c')
-rw-r--r--player/lua.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/player/lua.c b/player/lua.c
index 8a2e3ec925..f46094f79c 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -1422,9 +1422,14 @@ static int subprocess(char **args, struct mp_cancel *cancel, void *ctx,
done:
for (int i = 0; i < 2; i++) {
- if (pipes[i].ol.hEvent) CloseHandle(pipes[i].ol.hEvent);
- if (pipes[i].read) CloseHandle(pipes[i].read);
+ if (pipes[i].read) {
+ // Cancel any pending I/O (if the process was killed)
+ CancelIo(pipes[i].read);
+ GetOverlappedResult(pipes[i].read, &pipes[i].ol, &r, TRUE);
+ CloseHandle(pipes[i].read);
+ }
if (pipes[i].write) CloseHandle(pipes[i].write);
+ if (pipes[i].ol.hEvent) CloseHandle(pipes[i].ol.hEvent);
}
if (pi.hProcess) CloseHandle(pi.hProcess);
talloc_free(tmp);