mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
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:
parent
223ee40fde
commit
93bb7d8e19
@ -1271,6 +1271,8 @@ bufferevent_openssl_socket_new(struct event_base *base,
|
|||||||
/* Does the SSL already have an fd? */
|
/* Does the SSL already have an fd? */
|
||||||
BIO *bio = SSL_get_wbio(ssl);
|
BIO *bio = SSL_get_wbio(ssl);
|
||||||
long have_fd = -1;
|
long have_fd = -1;
|
||||||
|
const int shutdown_flag = !!(options & BEV_OPT_CLOSE_ON_FREE);
|
||||||
|
|
||||||
if (bio)
|
if (bio)
|
||||||
have_fd = BIO_get_fd(bio, NULL);
|
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. */
|
This is probably an error on our part. Fail. */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
(void) BIO_set_close(bio, shutdown_flag);
|
||||||
} else {
|
} else {
|
||||||
/* The SSL isn't configured with a BIO with an fd. */
|
/* The SSL isn't configured with a BIO with an fd. */
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
/* ... and we have an fd we want to use. */
|
/* ... 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);
|
bio = BIO_new_socket(fd, shutdown_flag);
|
||||||
SSL_set_bio(ssl, bio, bio);
|
SSL_set_bio(ssl, bio, bio);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user