Commit Diff


commit - e3693ed949ccfcad6170d85b2db9e86499e1fc52
commit + 0d6af421ea503c1facc0ce4dab1c08ee59f5b235
blob - 8319888390074988e37923f81927ba6444f75144
blob + c43bcb28fa4fc8ea2a41a7c700b4cf67942504df
--- bufio.c
+++ bufio.c
@@ -119,16 +119,25 @@ bufio_init(struct bufio *bio)
 	return (0);
 }
 
-int
-bufio_reset(struct bufio *bio)
+void
+bufio_free(struct bufio *bio)
 {
 	if (bio->ctx)
-		tls_close(bio->ctx);
+		tls_free(bio->ctx);
+	bio->ctx = NULL;
+
 	if (bio->fd != -1)
 		close(bio->fd);
+	bio->fd = -1;
 
 	buf_free(&bio->rbuf);
 	buf_free(&bio->wbuf);
+}
+
+int
+bufio_reset(struct bufio *bio)
+{
+	bufio_free(bio);
 	return (bufio_init(bio));
 }
 
blob - 5be149eb5327ad6dd1d497ad233891c773e86a31
blob + c8243a97c51d802157250d6ded3c1991bc081591
--- bufio.h
+++ bufio.h
@@ -48,8 +48,8 @@ void	buf_drain_line(struct buf *, const char *);
 void	buf_free(struct buf *);
 
 int	bufio_init(struct bufio *);
+void	bufio_free(struct bufio *);
 int	bufio_reset(struct bufio *);
-int	bufio_reset(struct bufio *);
 void	bufio_set_fd(struct bufio *, int);
 int	bufio_starttls(struct bufio *, const char *, int);
 short	bufio_pollev(struct bufio *);