]> git.sesse.net Git - vlc/commitdiff
decomp: fix potential deadlock at EOF
authorRémi Denis-Courmont <remi@remlab.net>
Fri, 26 Mar 2010 17:37:15 +0000 (19:37 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 26 Mar 2010 17:37:15 +0000 (19:37 +0200)
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
modules/stream_filter/decomp.c

index fd5c1edd87233d79a8d742fb041d342c65cdb59a..ec81167af85f61842d26267c2f46e52349297bbe 100644 (file)
@@ -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);