SSL write may do partial writes in some cases. For example, document
of mbedtls_ssl_write says:
If the return value is non-negative but less than length, the function
must be called again with updated arguments: buf + ret, len - ret
(if ret is the return value) until it returns a value equal to the
last 'len' argument.
In case of partial writes, we should continue writing the same chain of
buffer, not the next chain.
This will avoid this icky error:
$ https-client -4 -url https://127.1
some request failed - no idea which one though!
error:00000005:lib(0):func(0):DH lib
And instead will report only:
$ https-client -4 -url https://127.1
some request failed - no idea which one though!
socket error = Connection refused (111)
Refs: #1115
This patch splits common part out to avoid copy-paste from the
- bufferevent_openssl.c
- bufferevent_mbedtls.c
It uses VFS/bufferevent-like approach, i.e. structure of callbacks.