[vlc-devel] [PATCH] Avoid deadlock on UDP stop

Romain Vimont rom at rom1v.com
Tue May 20 17:11:13 CEST 2014


Hi Rémi,

Your answer is quite abrupt and I would have appreciated more arguments
;-)

The UDP access module uses 2 threads since commit 57eee64: one reading
from the network and writing to a fifo queue (ThreadRead(), let's call
it TR), the other reading from the queue (calling BlockUDP(), let's call
it BU).

A deadlock can happen because the TR call to block_FifoWake() is not
sufficient to prevent BU from blocking in block_FifoGet(): it only wakes
up once, by design (apparently). The purpose of b_finishing is to
prevent block_FifoGet() to be called in BU once ThreadRead() is finished
(because in that case, the queue would remain empty forever).

The flag b_eof must be accessed exclusively in the BU thread, while
b_finishing is shared between TR and BU.

I understand that a patch supposed to fix a deadlock needs to be tested.

Therefore, I wrote a sample Android project, so that you can test with
('master' branch) and without ('deadlockfix' branch) the patch:
https://github.com/rom1v/vlc-udp-deadlock

Everything is explained in the README.

Regards

--
®om


Le vendredi 16 mai 2014 à 22:40 +0800, Rémi Denis-Courmont a écrit :
> Le 2014-05-16 22:04, Romain Vimont a écrit :
> >OK, so we agree that we need another variable (b_finishing),
> >synchronized, to be written from another thread calling ThreadRead() and
> >read in BlockUDP(), as implemented in this patch?
> 
> No.
> 
> -- 
> Rémi Denis-Courmont
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list