[gnutls-help] Regression bug between 2.x and 3.2?

Lavrentiev, Anton (NIH/NLM/NCBI) [C] lavr at ncbi.nlm.nih.gov
Tue Jun 17 15:45:39 CEST 2014

> as there are more cases where GNUTLS_E_AGAIN doesn't directly map to EAGAIN errno.

Studying the current GNUTLS source, it looks like the added case is for exactly short writes,
which errno_to_gerr() supports.  The other place is for short read, but since the pull
callback is wrapped into the "while (left > 0)" loop (gnutls_stream_read), it is a legitimate
case, which also maps correctly.  I still can't understand why the similar loop "while (left > 0)"
was dropped off gnutls_io_write_flush (formerly part of gnutls_io_write_buffered) between 2.x and 3.x.

Anyhow, I'm going to modify our push callback behavior to do a tight loop around the former
push callback.  Doing so I notice that reading and writing are no longer symmetrical:
the pull callback does not require the looping on short reads as it will be done by GNUTLS,
and the push callback requires the looping because GNUTLS now bails out on short writes.

So for the sake of performance, the push callback should not return prematurely in order to
save on a long chain of returns with the only purpose to be followed by just a repeat of
gnutls_record_send(), which thus, can be avoided altogether...

Anton Lavrentiev
Contractor NIH/NLM/NCBI

More information about the Gnutls-help mailing list