[vlc-commits] udp: fix locking (fixes #14234) and cancellation

Rémi Denis-Courmont git at videolan.org
Mon Mar 23 22:39:29 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar 23 23:31:53 2015 +0200| [b70d2acf4c2e9be5af44d88c4968f4173f75376d] | committer: Rémi Denis-Courmont

udp: fix locking (fixes #14234) and cancellation

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

 modules/access/udp.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/modules/access/udp.c b/modules/access/udp.c
index 0a23317..c61bf8a 100644
--- a/modules/access/udp.c
+++ b/modules/access/udp.c
@@ -258,9 +258,6 @@ static void* ThreadRead( void *data )
     access_t *access = data;
     access_sys_t *sys = access->p_sys;
 
-    vlc_fifo_Lock(sys->fifo);
-    vlc_fifo_CleanupPush(sys->fifo);
-
     for(;;)
     {
         block_t *pkt = block_Alloc(MTU);
@@ -283,16 +280,22 @@ static void* ThreadRead( void *data )
 
         pkt->i_buffer = len;
 
+        vlc_fifo_Lock(sys->fifo);
         /* Discard old buffers on overflow */
         while (vlc_fifo_GetBytes(sys->fifo) + len > sys->fifo_size)
+        {
+            int canc = vlc_savecancel();
             block_Release(vlc_fifo_DequeueUnlocked(sys->fifo));
+            vlc_restorecancel(canc);
+        }
 
         vlc_fifo_QueueUnlocked(sys->fifo, pkt);
+        vlc_fifo_Unlock(sys->fifo);
     }
 
+    vlc_fifo_Lock(sys->fifo);
     sys->running = false;
     vlc_fifo_Signal(sys->fifo);
-    vlc_cleanup_run();
-
+    vlc_fifo_Unlock(sys->fifo);
     return NULL;
 }



More information about the vlc-commits mailing list