修正当进程句柄限制不足时,存在的随机关闭FD的问题并调整SSL关闭时的fd处理位置。

* 原实现在接收fd时,没有考虑可能只接收1个fd的情况。导致程序在接收1个fd时按2个fd处理,越界访问随机关闭fd。
* 现修正,接收2个一下fd时,关闭接收的fd。
* 同时调整SSL连接的FD关闭位置,改为在conn_private销毁时统一关闭,不在ssl部分关闭。
This commit is contained in:
luqiuwen
2019-09-05 16:16:51 +08:00
parent c9d814e17b
commit 611d978b91
4 changed files with 35 additions and 17 deletions

View File

@@ -2121,7 +2121,7 @@ complete:
* Guarantees that SSL and the corresponding SSL_CTX are freed and the
* socket is closed, eventually, or in the case of fatal errors, immediately.
*/
void ssl_stream_free_and_close_fd(struct ssl_stream * s_stream, struct event_base * evbase, struct bufferevent * bev)
void ssl_stream_free(struct ssl_stream * s_stream, struct event_base * evbase, struct bufferevent * bev)
{
UNUSED struct ssl_shutdown_ctx * sslshutctx = NULL;
evutil_socket_t fd=-1;
@@ -2165,8 +2165,8 @@ void ssl_stream_free_and_close_fd(struct ssl_stream * s_stream, struct event_bas
bufferevent_setcb(ubev, NULL, NULL, NULL, NULL);
bufferevent_free(ubev);
}
ssl_stream_free(s_stream);
evutil_closesocket(fd);
}
int ssl_manager_add_trust_ca(struct ssl_mgr* mgr, const char* pem_file)