tls: deal with gnutls's internal buffering of un-sent data
Submitted by Aleix Conchillo Flaqué
Link to original bug (#739983)
Description
Created attachment 290434 add flush support
This comes from bug 739799.
GStreamer sometimes doesn't resend the same data even after receiving G_IO_ERROR_WOULD_BLOCK. This is in gst_rtsp_watch_set_flushing.
It then tries to send new data on the stream. However, GnuTLS is still expecting the same old data that couldn't be sent. This causes GnuTLS to return the old size instead of the new requested size (because it has sent the buffered data).
Implementing the flush method would solve this problem as GStreamer could call g_output_stream_flush before trying to send any new data.
May be this is all wrong and GStreamer should really send the old data instead of discarding it.
From the commit log:
GnuTLS buffers already encrypted data in gnutls_record_send when
returning EAGAIN or EINTR. This means a user can call again
gnutls_record_send with NULL and 0 and the previous data will be
sent.
This patch implements GOutputStream flush method by calling
gnutls_record_send with NULL and 0 and thus making sure no data is
buffered by GnuTLS.
Patch 290434, "add flush support":
0001-gnutls-implement-output-stream-flush.patch