summaryrefslogtreecommitdiff
path: root/platform/src/ssl_stream.cpp
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2021-08-10 15:17:42 +0800
committerluwenpeng <[email protected]>2021-08-10 15:17:42 +0800
commit4c0b732a0f0d2295707542677cead3313c2a1a0f (patch)
treedf5e633bdc1a0ce99302d4ff89992cb863467945 /platform/src/ssl_stream.cpp
parent95d05be3381bc101631b4716bd0cf979320c7385 (diff)
bugfix: TSG-7333 Proxy使用ssl_stream_log_error打印错误日志时频繁调用asprintf()/free()拼接四元组字符串v4.5.10-202108
Diffstat (limited to 'platform/src/ssl_stream.cpp')
-rw-r--r--platform/src/ssl_stream.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/platform/src/ssl_stream.cpp b/platform/src/ssl_stream.cpp
index 865e623..55f3924 100644
--- a/platform/src/ssl_stream.cpp
+++ b/platform/src/ssl_stream.cpp
@@ -1083,11 +1083,10 @@ static void ssl_stream_set_cmsg_integer(struct ssl_stream* stream, enum tfe_cmsg
return;
}
-unsigned long ssl_stream_log_error(struct bufferevent * bev, enum tfe_conn_dir dir, struct ssl_mgr* mgr)
+unsigned long ssl_stream_log_error(struct bufferevent * bev, enum tfe_conn_dir dir, struct ssl_mgr* mgr, const char *addr)
{
unsigned long sslerr=0, ret_sslerr=0;
int fd=bufferevent_getfd(bev);
- char* addr_string=tfe_string_addr_create_by_fd(fd, dir);
void* logger=mgr->logger;
int fs_id=-1;
@@ -1134,7 +1133,7 @@ unsigned long ssl_stream_log_error(struct bufferevent * bev, enum tfe_conn_dir d
TFE_LOG_ERROR(logger,"Handshake Error from bufferevent of ssl %s %s: "
"%i:%s %lu:%i:%s:%i:%s:%i:%s",
tfe_stream_conn_dir_to_str(dir),
- addr_string,
+ addr,
errno,
errno ? strerror(errno) : "-",
sslerr,
@@ -1168,7 +1167,7 @@ unsigned long ssl_stream_log_error(struct bufferevent * bev, enum tfe_conn_dir d
TFE_LOG_ERROR(logger,"Error from bufferevent of ssl %s %s: "
"%i:%s %lu:%i:%s:%i:%s:%i:%s",
tfe_stream_conn_dir_to_str(dir),
- addr_string,
+ addr,
errno,
errno ? strerror(errno) : "-",
sslerr,
@@ -1196,7 +1195,6 @@ unsigned long ssl_stream_log_error(struct bufferevent * bev, enum tfe_conn_dir d
ERR_func_error_string(sslerr));
}
}
- free(addr_string);
return ret_sslerr;
}
void ssl_stream_process_error(struct ssl_stream * s_stream, unsigned long sslerr, struct ssl_mgr* mgr)
@@ -1283,7 +1281,7 @@ static void ssl_server_connected_eventcb(struct bufferevent * bev, short events,
if (events & BEV_EVENT_ERROR)
{
ATOMIC_INC(&(ctx->mgr->stat_val[SSL_UP_ERR]));
- sslerr=ssl_stream_log_error(bev, CONN_DIR_UPSTREAM, ctx->mgr);
+ sslerr=ssl_stream_log_error(bev, CONN_DIR_UPSTREAM, ctx->mgr, s_stream->tcp_stream->str_stream_info);
if(sslerr)
{
ssl_stream_process_error(s_stream, sslerr, mgr);
@@ -1898,7 +1896,7 @@ static void ssl_client_connected_eventcb(struct bufferevent * bev, short events,
if (events & BEV_EVENT_ERROR)
{
ATOMIC_INC(&(mgr->stat_val[SSL_DOWN_ERR]));
- sslerr=ssl_stream_log_error(bev, CONN_DIR_DOWNSTREAM, mgr);
+ sslerr=ssl_stream_log_error(bev, CONN_DIR_DOWNSTREAM, mgr, s_stream->tcp_stream->str_stream_info);
if(sslerr)
{
ssl_stream_process_error(s_stream, sslerr, mgr);
@@ -2046,7 +2044,7 @@ void ssl_stream_free(struct ssl_stream * s_stream, struct event_base * evbase, s
if(errno)
{
- sslerr=ssl_stream_log_error(bev, s_stream->dir, s_stream->mgr);
+ sslerr=ssl_stream_log_error(bev, s_stream->dir, s_stream->mgr, s_stream->tcp_stream->str_stream_info);
if(sslerr)
{
ssl_stream_process_error(s_stream, sslerr, s_stream->mgr);