summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2015-09-10 13:23:57 +0000
committerjsing <>2015-09-10 13:23:57 +0000
commit5c084c7f0a975a7ee5f9c0458c051abd6685c259 (patch)
treec8ebaa96ab003a31397e3205a705f929dcf871b4
parent1ede37579e4cc08560f78fbdfce88b0ddaffc6ab (diff)
downloadopenbsd-5c084c7f0a975a7ee5f9c0458c051abd6685c259.tar.gz
openbsd-5c084c7f0a975a7ee5f9c0458c051abd6685c259.tar.bz2
openbsd-5c084c7f0a975a7ee5f9c0458c051abd6685c259.zip
Replace TLS_{READ,WRITE}_AGAIN with TLS_WANT_POLL{IN,OUT} and correctly
document the calling requirements. ok beck@
-rw-r--r--src/lib/libtls/tls_init.333
1 files changed, 13 insertions, 20 deletions
diff --git a/src/lib/libtls/tls_init.3 b/src/lib/libtls/tls_init.3
index 70493fae03..6389a96722 100644
--- a/src/lib/libtls/tls_init.3
+++ b/src/lib/libtls/tls_init.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_init.3,v 1.29 2015/09/10 11:21:08 jsing Exp $ 1.\" $OpenBSD: tls_init.3,v 1.30 2015/09/10 13:23:57 jsing Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" 4.\"
@@ -442,32 +442,25 @@ and
442.Fn tls_close 442.Fn tls_close
443functions have two special return values: 443functions have two special return values:
444.Pp 444.Pp
445.Bl -tag -width "TLS_WRITE_AGAIN" -offset indent -compact 445.Bl -tag -width "TLS_WANT_POLLOUT" -offset indent -compact
446.It Dv TLS_READ_AGAIN 446.It Dv TLS_WANT_POLLIN
447A read operation is necessary to continue. 447The underlying read file descriptor needs to be readable in order to continue.
448.It Dv TLS_WRITE_AGAIN 448.It Dv TLS_WANT_POLLOUT
449A write operation is necessary to continue. 449The underlying write file descriptor needs to be writeable in order to continue.
450.El 450.El
451.Pp 451.Pp
452There are underlying TLS engine read or write operations which may 452In the case of blocking file descriptors, the same function call should be
453not correspond with the name of the function called. 453repeated immediately.
454For example, it is possible to receive a 454In the case of non-blocking file descriptors, the same function call should be
455.Dv TLS_READ_AGAIN 455repeated when the required condition has been met.
456even when calling
457.Fn tls_write .
458.Pp
459While there are cases where these functions will return one or the
460other or both, the best practice is to always check for both.
461In all cases the same function call should be repeated.
462.Sh EXAMPLES 456.Sh EXAMPLES
463Example showing how to handle partial TLS writes. 457Example showing how to handle TLS writes.
464.Bd -literal -offset indent 458.Bd -literal -offset indent
465\&... 459\&...
466while (len > 0) { 460while (len > 0) {
467 ret = tls_write(ctx, buf, len, &num_written); 461 ret = tls_write(ctx, buf, len, &num_written);
468 462 if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT) {
469 if (ret == TLS_READ_AGAIN || ret == TLS_WRITE_AGAIN) { 463 /* Retry - use select to wait for non-blocking. */
470 /* retry. May use select to wait for nonblocking */
471 } else if (ret < 0) { 464 } else if (ret < 0) {
472 return -1; 465 return -1;
473 } else { 466 } else {