diff options
-rw-r--r-- | src/lib/libtls/tls_bio_cb.c | 24 |
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 | |||
169 | tls_bio_write_cb(BIO *h, const char *buf, int num, void *cb_arg) | 169 | tls_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 | ||
175 | static int | 184 | static int |
176 | tls_bio_read_cb(BIO *h, char *buf, int size, void *cb_arg) | 185 | tls_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 | ||
182 | static BIO * | 200 | static BIO * |