mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-10 13:04:23 -04:00
Merge remote branches 'github/20_epoll_nochangelist_v4', 'github/20_openssl_closeonfree' and 'github/20_cloexec'
This commit is contained in:
commit
568ac4fd1b
@ -1086,6 +1086,13 @@ be_openssl_destruct(struct bufferevent *bev)
|
|||||||
bufferevent_free(bev_ssl->underlying);
|
bufferevent_free(bev_ssl->underlying);
|
||||||
bev_ssl->underlying = NULL;
|
bev_ssl->underlying = NULL;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
evutil_socket_t fd = -1;
|
||||||
|
BIO *bio = SSL_get_wbio(bev_ssl->ssl);
|
||||||
|
if (bio)
|
||||||
|
fd = BIO_get_fd(bio, NULL);
|
||||||
|
if (fd >= 0)
|
||||||
|
evutil_closesocket(fd);
|
||||||
}
|
}
|
||||||
SSL_free(bev_ssl->ssl);
|
SSL_free(bev_ssl->ssl);
|
||||||
} else {
|
} else {
|
||||||
@ -1134,11 +1141,8 @@ be_openssl_ctrl(struct bufferevent *bev,
|
|||||||
if (bev_ssl->underlying)
|
if (bev_ssl->underlying)
|
||||||
return -1;
|
return -1;
|
||||||
{
|
{
|
||||||
int flag = 0;
|
|
||||||
BIO *bio;
|
BIO *bio;
|
||||||
if (bev_ssl->bev.options & BEV_OPT_CLOSE_ON_FREE)
|
bio = BIO_new_socket(data->fd, 0);
|
||||||
flag = 1;
|
|
||||||
bio = BIO_new_socket(data->fd, flag);
|
|
||||||
SSL_set_bio(bev_ssl->ssl, bio, bio);
|
SSL_set_bio(bev_ssl->ssl, bio, bio);
|
||||||
bev_ssl->fd_is_set = 1;
|
bev_ssl->fd_is_set = 1;
|
||||||
}
|
}
|
||||||
@ -1294,7 +1298,6 @@ 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);
|
||||||
@ -1311,12 +1314,12 @@ 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);
|
(void) BIO_set_close(bio, 0);
|
||||||
} 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. */
|
||||||
bio = BIO_new_socket(fd, shutdown_flag);
|
bio = BIO_new_socket(fd, 0);
|
||||||
SSL_set_bio(ssl, bio, bio);
|
SSL_set_bio(ssl, bio, bio);
|
||||||
} else {
|
} else {
|
||||||
/* Leave the fd unset. */
|
/* Leave the fd unset. */
|
||||||
|
15
event.c
15
event.c
@ -2676,8 +2676,12 @@ evthread_make_base_notifiable(struct event_base *base)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#if defined(_EVENT_HAVE_EVENTFD) && defined(_EVENT_HAVE_SYS_EVENTFD_H)
|
#if defined(_EVENT_HAVE_EVENTFD) && defined(_EVENT_HAVE_SYS_EVENTFD_H)
|
||||||
base->th_notify_fd[0] = eventfd(0, 0);
|
#ifndef EFD_CLOEXEC
|
||||||
|
#define EFD_CLOEXEC 0
|
||||||
|
#endif
|
||||||
|
base->th_notify_fd[0] = eventfd(0, EFD_CLOEXEC);
|
||||||
if (base->th_notify_fd[0] >= 0) {
|
if (base->th_notify_fd[0] >= 0) {
|
||||||
|
evutil_make_socket_closeonexec(base->th_notify_fd[0]);
|
||||||
notify = evthread_notify_base_eventfd;
|
notify = evthread_notify_base_eventfd;
|
||||||
cb = evthread_notify_drain_eventfd;
|
cb = evthread_notify_drain_eventfd;
|
||||||
}
|
}
|
||||||
@ -2685,8 +2689,12 @@ evthread_make_base_notifiable(struct event_base *base)
|
|||||||
#if defined(_EVENT_HAVE_PIPE)
|
#if defined(_EVENT_HAVE_PIPE)
|
||||||
if (base->th_notify_fd[0] < 0) {
|
if (base->th_notify_fd[0] < 0) {
|
||||||
if ((base->evsel->features & EV_FEATURE_FDS)) {
|
if ((base->evsel->features & EV_FEATURE_FDS)) {
|
||||||
if (pipe(base->th_notify_fd) < 0)
|
if (pipe(base->th_notify_fd) < 0) {
|
||||||
event_warn("%s: pipe", __func__);
|
event_warn("%s: pipe", __func__);
|
||||||
|
} else {
|
||||||
|
evutil_make_socket_closeonexec(base->th_notify_fd[0]);
|
||||||
|
evutil_make_socket_closeonexec(base->th_notify_fd[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2701,6 +2709,9 @@ evthread_make_base_notifiable(struct event_base *base)
|
|||||||
base->th_notify_fd) == -1) {
|
base->th_notify_fd) == -1) {
|
||||||
event_sock_warn(-1, "%s: socketpair", __func__);
|
event_sock_warn(-1, "%s: socketpair", __func__);
|
||||||
return (-1);
|
return (-1);
|
||||||
|
} else {
|
||||||
|
evutil_make_socket_closeonexec(base->th_notify_fd[0]);
|
||||||
|
evutil_make_socket_closeonexec(base->th_notify_fd[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user