Commit b70d2acf authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

udp: fix locking (fixes #14234) and cancellation

parent f35c3d11
...@@ -258,9 +258,6 @@ static void* ThreadRead( void *data ) ...@@ -258,9 +258,6 @@ static void* ThreadRead( void *data )
access_t *access = data; access_t *access = data;
access_sys_t *sys = access->p_sys; access_sys_t *sys = access->p_sys;
vlc_fifo_Lock(sys->fifo);
vlc_fifo_CleanupPush(sys->fifo);
for(;;) for(;;)
{ {
block_t *pkt = block_Alloc(MTU); block_t *pkt = block_Alloc(MTU);
...@@ -283,16 +280,22 @@ static void* ThreadRead( void *data ) ...@@ -283,16 +280,22 @@ static void* ThreadRead( void *data )
pkt->i_buffer = len; pkt->i_buffer = len;
vlc_fifo_Lock(sys->fifo);
/* Discard old buffers on overflow */ /* Discard old buffers on overflow */
while (vlc_fifo_GetBytes(sys->fifo) + len > sys->fifo_size) while (vlc_fifo_GetBytes(sys->fifo) + len > sys->fifo_size)
{
int canc = vlc_savecancel();
block_Release(vlc_fifo_DequeueUnlocked(sys->fifo)); block_Release(vlc_fifo_DequeueUnlocked(sys->fifo));
vlc_restorecancel(canc);
}
vlc_fifo_QueueUnlocked(sys->fifo, pkt); vlc_fifo_QueueUnlocked(sys->fifo, pkt);
vlc_fifo_Unlock(sys->fifo);
} }
vlc_fifo_Lock(sys->fifo);
sys->running = false; sys->running = false;
vlc_fifo_Signal(sys->fifo); vlc_fifo_Signal(sys->fifo);
vlc_cleanup_run(); vlc_fifo_Unlock(sys->fifo);
return NULL; return NULL;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment