[rtmpdump] librtmp thread-safeness question

Rafaël Carré funman at videolan.org
Wed Dec 17 09:25:27 CET 2014


Hi,

Le 16/12/2014 12:46, Andrey Turkin a écrit :
> Hi all,
> 
> I've run into an issue with streaming to RTMP server (via libav) in
> multithreaded application - it would sometimes crash at start.
> 
> Debugging revealed following (reduced) callstack:
> 
> openssl!lh_insert
> openssl!int_err_set_item
> ...
> openssl!SSL_load_error_strings
> librtmp!RTMP_TLS_Init
> librtmp!RTMP_Init
> libavformat!rtmp_open
> ...
> libavformat!avio_open2
> my application
> 
> After reading openssl/librtmp/libav code it seems to me that there is
> not one but two different race conditions. Firstly, there is an
> obvious race in RTMP_Init before and during the call to RTMP_TLS_Init.

Check this patch:
https://lists.mplayerhq.hu/pipermail/rtmpdump/2014-September/002380.html

> Secondly, although openssl is supposed to be threadsafe, it is only
> true if its threading support is initialized via CRYPTO_thread_setup
> or alternative code which does something similar.
> 
> I don't know if that is a bug in librtmp or incorrect usage by libav
> or something else.
> 
> So, my question is whether librtmp is supposed to be thread-safe to a
> some degree; and if it is then which API calls are supposed to be
> thread-safe and which are not. I saw a message in this list which said
> calling librtmp functions with same session handle from different
> threads is not safe (which makes sense) but I cannot find any
> information about what usage should be safe.
> 
> From what I can see (with regard to not initialized openssl threading)
> it looks like librtmp is not thread-safe as a whole and all calls to
> it must be serialized.
> 
> Regards,
> 
>   Andrey Turkin
> 
> 
> 
> _______________________________________________
> rtmpdump mailing list
> rtmpdump at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/rtmpdump
> 



More information about the rtmpdump mailing list