[vlc-commits] commit: decomp: fix potential deadlock at EOF ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Fri Mar 26 18:38:57 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Mar 26 19:37:15 2010 +0200| [d9a20253a2c57aa7678375faf27feceab8c8923d] | committer: Rémi Denis-Courmont 

decomp: fix potential deadlock at EOF

The decompression process needs to "see" the end-of-file. Otherwise
it might get stuck, and then the demux thread will get stuck too.
Closing the write end of the pipe to the compression process fixes
that.

Pointed-out-by: Laurent Aimar

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d9a20253a2c57aa7678375faf27feceab8c8923d
---

 modules/stream_filter/decomp.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/modules/stream_filter/decomp.c b/modules/stream_filter/decomp.c
index fd5c1ed..ec81167 100644
--- a/modules/stream_filter/decomp.c
+++ b/modules/stream_filter/decomp.c
@@ -148,6 +148,9 @@ static void *Thread (void *data)
     while (!error);
 
     msg_Dbg (stream, "compressed stream at EOF");
+    /* Let child process know about EOF */
+    p_sys->write_fd = -1;
+    close (fd);
     return NULL;
 }
 
@@ -364,7 +367,9 @@ static void Close (vlc_object_t *obj)
     vlc_cancel (p_sys->thread);
     close (p_sys->read_fd);
     vlc_join (p_sys->thread, NULL);
-    close (p_sys->write_fd);
+    if (p_sys->write_fd != -1)
+        /* Killed before EOF? */
+        close (p_sys->write_fd);
 
     msg_Dbg (obj, "waiting for PID %u", (unsigned)p_sys->pid);
     while (waitpid (p_sys->pid, &status, 0) == -1);



More information about the vlc-commits mailing list