summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbcook <>2016-09-14 11:26:56 +0000
committerbcook <>2016-09-14 11:26:56 +0000
commit9dcaeaa99745c183e3791733b424d31c7bfb51a6 (patch)
tree0940beba6d0ee06a3eec448624261e8f32fe8d26 /src
parentceac7d2c6e91336c8238cc1345fe787251561abb (diff)
downloadopenbsd-9dcaeaa99745c183e3791733b424d31c7bfb51a6.tar.gz
openbsd-9dcaeaa99745c183e3791733b424d31c7bfb51a6.tar.bz2
openbsd-9dcaeaa99745c183e3791733b424d31c7bfb51a6.zip
Allow callback read/write functions to set TLS_WANT_POLLOUT/POLLIN.
from Tobias Pape
Diffstat (limited to 'src')
-rw-r--r--src/lib/libtls/tls_bio_cb.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/lib/libtls/tls_bio_cb.c b/src/lib/libtls/tls_bio_cb.c
index e689cf1117..bee52a67f4 100644
--- a/src/lib/libtls/tls_bio_cb.c
+++ b/src/lib/libtls/tls_bio_cb.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_bio_cb.c,v 1.3 2016/09/04 13:17:08 jsing Exp $ */ 1/* $OpenBSD: tls_bio_cb.c,v 1.4 2016/09/14 11:26:56 bcook Exp $ */
2/* 2/*
3 * Copyright (c) 2016 Tobias Pape <tobias@netshed.de> 3 * Copyright (c) 2016 Tobias Pape <tobias@netshed.de>
4 * 4 *
@@ -169,14 +169,32 @@ static int
169tls_bio_write_cb(BIO *h, const char *buf, int num, void *cb_arg) 169tls_bio_write_cb(BIO *h, const char *buf, int num, void *cb_arg)
170{ 170{
171 struct tls *ctx = cb_arg; 171 struct tls *ctx = cb_arg;
172 return (ctx->write_cb)(ctx, buf, num, ctx->cb_arg); 172 BIO_clear_retry_flags(h);
173 int rv = (ctx->write_cb)(ctx, buf, num, ctx->cb_arg);
174 if (rv == TLS_WANT_POLLIN) {
175 BIO_set_retry_read(h);
176 rv = -1;
177 } else if (rv == TLS_WANT_POLLOUT) {
178 BIO_set_retry_write(h);
179 rv = -1;
180 }
181 return (rv);
173} 182}
174 183
175static int 184static int
176tls_bio_read_cb(BIO *h, char *buf, int size, void *cb_arg) 185tls_bio_read_cb(BIO *h, char *buf, int size, void *cb_arg)
177{ 186{
178 struct tls *ctx = cb_arg; 187 struct tls *ctx = cb_arg;
179 return (ctx->read_cb)(ctx, buf, size, ctx->cb_arg); 188 BIO_clear_retry_flags(h);
189 int rv = (ctx->read_cb)(ctx, buf, size, ctx->cb_arg);
190 if (rv == TLS_WANT_POLLIN) {
191 BIO_set_retry_read(h);
192 rv = -1;
193 } else if (rv == TLS_WANT_POLLOUT) {
194 BIO_set_retry_write(h);
195 rv = -1;
196 }
197 return (rv);
180} 198}
181 199
182static BIO * 200static BIO *