On 07.09.2016, at 10:45, Tobias Pape <[email protected]> wrote:
> Hi there
>
> On 05.09.2016, at 15:50, [email protected] wrote:
>
>> Hey, the typedef came in handy :) Ok bcook@
>>
>> On Sep 5, 2016, at 11:52 AM, Bob Beck <[email protected]> wrote:
>>
>>> I am in agreement in principle, but please coordinate with bcook@ and/or
>>> jsing@ who were possibly doing
>>> some related adjustments.
>>>
>>>
>
> I have a minor adjustment: it should be able to instruct POLLIN/POLLOUT via
> the callbacks.
> I added this, see the diff.
Aaand: a fix for the FLUSH BIO cntl, that happens at the end of SSL handshakes…
Best regards
-Tobias
diff --git src/lib/libtls/tls_bio_cb.c src/lib/libtls/tls_bio_cb.c
index c4220df..e52f43c 100644
--- src/lib/libtls/tls_bio_cb.c
+++ src/lib/libtls/tls_bio_cb.c
@@ -154,6 +154,7 @@ ctrl_cb(BIO *b, int cmd, long num, void *ptr)
b->shutdown = (int)num;
break;
case BIO_CTRL_DUP:
+ case BIO_CTRL_FLUSH:
break;
case BIO_CTRL_INFO:
case BIO_CTRL_GET:
@@ -169,14 +170,32 @@ static int
tls_bio_write_cb(BIO *h, const char *buf, int num, void *cb_arg)
{
struct tls *ctx = cb_arg;
- return (ctx->write_cb)(ctx, buf, num, ctx->cb_arg);
+ BIO_clear_retry_flags(h);
+ int rv = (ctx->write_cb)(ctx, buf, num, ctx->cb_arg);
+ if (rv == TLS_WANT_POLLIN) {
+ BIO_set_retry_read(h);
+ rv = -1;
+ } else if (rv == TLS_WANT_POLLOUT) {
+ BIO_set_retry_write(h);
+ rv = -1;
+ }
+ return (rv);
}
static int
tls_bio_read_cb(BIO *h, char *buf, int size, void *cb_arg)
{
struct tls *ctx = cb_arg;
- return (ctx->read_cb)(ctx, buf, size, ctx->cb_arg);
+ BIO_clear_retry_flags(h);
+ int rv = (ctx->read_cb)(ctx, buf, size, ctx->cb_arg);
+ if (rv == TLS_WANT_POLLIN) {
+ BIO_set_retry_read(h);
+ rv = -1;
+ } else if (rv == TLS_WANT_POLLOUT) {
+ BIO_set_retry_write(h);
+ rv = -1;
+ }
+ return (rv);
}
static BIO *