Commit Diff


commit - 0d6af421ea503c1facc0ce4dab1c08ee59f5b235
commit + 8b00d570f2c7a3554b254a8947c60671d9001112
blob - c43bcb28fa4fc8ea2a41a7c700b4cf67942504df
blob + 206ee78efb1955999fa7b5f07b4d46e73115e8d3
--- bufio.c
+++ bufio.c
@@ -135,6 +135,25 @@ bufio_free(struct bufio *bio)
 }
 
 int
+bufio_close(struct bufio *bio)
+{
+	if (bio->ctx == NULL)
+		return (0);
+
+	switch (tls_close(bio->ctx)) {
+	case 0:
+		return 0;
+	case TLS_WANT_POLLIN:
+	case TLS_WANT_POLLOUT:
+		errno = EAGAIN;
+		bio->pflags = EV_READ | EV_WRITE;
+		/* fallthrough */
+	default:
+		return (-1);
+	}
+}
+
+int
 bufio_reset(struct bufio *bio)
 {
 	bufio_free(bio);
blob - c8243a97c51d802157250d6ded3c1991bc081591
blob + 417a36577d396e20330232c3d6a02e1fd7542a62
--- bufio.h
+++ bufio.h
@@ -49,6 +49,7 @@ void	buf_free(struct buf *);
 
 int	bufio_init(struct bufio *);
 void	bufio_free(struct bufio *);
+int	bufio_close(struct bufio *);
 int	bufio_reset(struct bufio *);
 void	bufio_set_fd(struct bufio *, int);
 int	bufio_starttls(struct bufio *, const char *, int);