gstreamer/ext
Alex Ashley c2fe4e58ad curlhttpsrc: fix various leaks and thread safety issues
curlhttpsrc uses a single thread running the
gst_curl_http_src_curl_multi_loop() function to handle receiving
data and messages from libcurl. Each instance of curlhttpsrc adds
an entry into a queue in GstCurlHttpSrcMultiTaskContext and waits
for the multi_loop to perform the HTTP request.

Valgrind has shown up race conditions and memory leaks:
1. gst_curl_http_src_change_state() does not wait for the multi_loop
   to complete before going to the NULL state, which means that
   an instance of GstCurlHttpSrc can be released while
   gst_curl_http_src_curl_multi_loop() still has a reference to it.
2. if multiple elements try to be removed from the queue at once,
   only the last one is deleted.
3. source->caps is leaked
4. curl multi_handle is leaked
5. leak of curl_handle if URI not set
6. leak of http_headers when reusing element
7. null pointer dereference in negotiate caps
8. double-free of the default user-agent string
9. leak of multi_task_context.task

This commit changes the logic so that each element has a connection
status, which is used by the multi_loop to decide when to remove an
element from its queue. An instance of curlhttpsrc will not enter
the NULL state until its reference has been removed from the queue.

When shutting down the curl multi loop, the memory allocated from the
call to curl_multi_init() is now released.

When gstadaptivedemux uses a URI source element, it will re-use
it for multiple requests, moving it between READY and PLAYING
between each request. curlhttpsrc was leaking the http_headers
structure in this use case.

The gst_curl_http_src_negotiate_caps() function extracts the
"response-headers" field from the http_headers, but did not check
that this field might be NULL.

If the user-agent property is set, the global user-agent string
was freed. This caused a double-free error if the user-agent is
ever set a second time during the execution of the process.

There are situations within curlhttpsrc where the code needs
both the global multi_task_context mutex and the per-element
buffer_mutex. To avoid deadlocks, it is vital that the order in
which these are requested is always the same. This commit modifies
the locking order to always be in the order:
 1. multi_task_context.task_rec_mutex
 2. buffer_mutex

Fixes 
2019-02-19 17:55:12 +00:00
..
aom av1enc: Add to configure image formats 2018-10-10 15:44:34 -04:00
assrender assrender: fix multiple subtitles on screen simultaneously 2018-08-14 23:00:34 +10:00
bs2b Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
bz2 Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
chromaprint Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
closedcaption closedcaption: Use portable variadic macro syntax 2019-02-15 23:50:11 +05:30
colormanagement colormanagement: Link to libgstbase for basetransform 2018-02-18 12:01:07 +02:00
curl curlhttpsrc: fix various leaks and thread safety issues 2019-02-19 17:55:12 +00:00
dash dashdemux: Always create the adapter 2018-08-16 15:59:42 -04:00
dc1394 meson: build dc1394 plugin 2018-12-17 09:12:53 +00:00
directfb Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
dtls dtls: Don't abort on non-fatal issues 2019-02-13 17:48:46 +00:00
dts meson: Don't pass GNU-like compiler wargs on MSVC 2018-09-05 21:31:22 +05:30
faac Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
faad Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
fdkaac fdkaacenc: Fix draining with libfdk-aac v2.0.0 2019-02-13 16:12:03 +01:00
flite Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
fluidsynth Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
gme meson: build gme plugin 2018-12-17 09:12:53 +00:00
gsm Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
hls hlssink2: Fix string leak 2018-11-27 16:08:17 +09:00
iqa Remove GstVideoAggregator, moved into libgstvideo in -base 2018-12-26 19:06:33 +01:00
kate Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
ladspa misc: Fix warnings on Cerbero MinGW 2019-02-06 00:10:28 +05:30
libde265 Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
libmms Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
lv2 Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
modplug meson: build modplug plugin 2018-12-17 09:12:53 +00:00
mpeg2enc meson: mjpegtools_api should have been 20K not 2K 2018-07-27 22:33:47 -04:00
mplex meson: mjpegtools_api should be 20K for mplex too 2018-07-27 22:36:40 -04:00
musepack meson: build musepack plugin 2018-08-19 15:50:25 +01:00
neon meson: build neonhttpsrc 2018-08-19 01:11:38 +01:00
ofa meson: build ofa plugin 2018-12-17 09:12:53 +00:00
openal openal: Fix AL header path for Mac OS X 2018-12-25 00:42:31 +09:00
opencv opencv cameraundistort: use G_GNUC_UNUSED for better portability 2019-02-02 18:34:10 +00:00
openexr meson: build openexr plugin 2018-12-17 09:12:53 +00:00
openh264 openh264dec: Fix build with msvc 2019-02-11 21:21:52 +09:00
openjpeg Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
openmpt meson: build openmpt plugin 2018-12-17 09:12:53 +00:00
openni2 meson: build openni2 plugin 2018-12-17 09:12:53 +00:00
opus Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
resindvd Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
rsvg rsvg: Also accept </svg:svg> as ending tag 2018-08-02 21:11:14 -04:00
rtmp rtmpsink: Fix leak on connection failure 2018-08-31 10:03:35 +03:00
sbc Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
sctp sctp: link against ws2_32 on windows 2018-10-17 21:07:36 +11:00
smoothstreaming Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
sndfile meson: Add libsinc to the CFLAGS 2018-12-17 12:30:27 +02:00
soundtouch build: link against the gnustl dependency on android for c++ plugins 2018-11-12 21:37:07 +11:00
spandsp Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
srt srt: re-enable passphrase 2019-02-11 23:40:02 +00:00
srtp srtpenc: Add support for adding a MKI 2018-11-09 15:08:05 -05:00
teletextdec meson: build teletext plugin 2018-12-17 09:12:53 +00:00
ttml Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
voaacenc Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
voamrwbenc meson: build voamrwbenc plugin 2018-12-17 09:12:53 +00:00
vulkan Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
wayland waylandsink: Don't create throwaway empty regions 2019-02-15 12:03:48 +00:00
webp Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
webrtc webrtc: fix rtx + bundle 2019-02-15 08:19:51 +00:00
webrtcdsp build: link against the gnustl dependency on android for c++ plugins 2018-11-12 21:37:07 +11:00
wildmidi meson: wildmidi detection fixes 2018-12-17 17:11:00 +00:00
wpe wpesrc: Plug WPE's exportable leak 2019-01-22 11:52:30 +00:00
x265 Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
zbar Add feature options for almost all plugins 2018-07-27 19:04:38 +05:30
Makefile.am wpe: Add autotools build support 2019-01-22 11:13:13 +00:00
meson.build Remove openglmixers plugin, moved to -base 2018-12-28 13:48:29 +01:00