Fix a case where an ssl bufferevent with CLOSE_ON_FREE didn't close its fd

This could happen when we got an SSL with a BIO already set on it.
This commit is contained in:
Nick Mathewson 2010-10-14 11:41:10 -04:00
parent 223ee40fde
commit 93bb7d8e19

View File

@ -1271,6 +1271,8 @@ bufferevent_openssl_socket_new(struct event_base *base,
/* Does the SSL already have an fd? */
BIO *bio = SSL_get_wbio(ssl);
long have_fd = -1;
const int shutdown_flag = !!(options & BEV_OPT_CLOSE_ON_FREE);
if (bio)
have_fd = BIO_get_fd(bio, NULL);
@ -1286,13 +1288,11 @@ bufferevent_openssl_socket_new(struct event_base *base,
This is probably an error on our part. Fail. */
return NULL;
}
(void) BIO_set_close(bio, shutdown_flag);
} else {
/* The SSL isn't configured with a BIO with an fd. */
if (fd >= 0) {
/* ... and we have an fd we want to use. */
int shutdown_flag = 0;
if (options & BEV_OPT_CLOSE_ON_FREE)
shutdown_flag = 1;
bio = BIO_new_socket(fd, shutdown_flag);
SSL_set_bio(ssl, bio, bio);
} else {