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. Best regards -Tobias diff --git src/lib/libtls/tls_bio_cb.c src/lib/libtls/tls_bio_cb.c index c4220df..acc8a8a 100644 --- src/lib/libtls/tls_bio_cb.c +++ src/lib/libtls/tls_bio_cb.c @@ -169,14 +169,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 *
