diff --git a/platform/src/tcp_stream.cpp b/platform/src/tcp_stream.cpp index c60500c..aeccd8f 100644 --- a/platform/src/tcp_stream.cpp +++ b/platform/src/tcp_stream.cpp @@ -912,28 +912,7 @@ static void __stream_bev_eventcb(struct bufferevent * bev, short events, void * const char * str_conn_dir = __str_dir(conn_dir); enum tfe_conn_dir peer_conn_dir{}; size_t rx_offset = 0; - - if (steering_device_is_available() && ( - (STREAM_PROTO_PLAIN == _stream->session_type && _stream->proxy_ref->traffic_steering_options.enable_steering_http) || - (STREAM_PROTO_SSL == _stream->session_type &&_stream->proxy_ref->traffic_steering_options.enable_steering_ssl))) - { - TFE_LOG_DEBUG(__STREAM_LOGGER(_stream), "decrypted traffic steering, %s %s run eventcb, %s %s", - _stream->str_stream_addr, - bev == _stream->conn_downstream->bev ? "conn_downstream" : "conn_upstream", - bev_event_to_string(events), - errno_to_string(errno) - ); - if (events & BEV_EVENT_ERROR) - { - __stream_log_event(_stream, EVENT_LOG_CLOSE_BY_FD_ERROR, conn_dir, errno, errno_to_string(errno)); - } - if (events & BEV_EVENT_EOF) - { - __stream_log_event(_stream, EVENT_LOG_CLOSE_BY_FD_EOF, conn_dir, errno, errno_to_string(errno)); - } - tfe_stream_destory(_stream); - return; - } + int need_close_connection = 0; if (__bev_dir(_stream, bev) == CONN_DIR_UPSTREAM) { @@ -986,8 +965,6 @@ static void __stream_bev_eventcb(struct bufferevent * bev, short events, void * { TFE_LOG_INFO(g_default_logger, "%s %s connection error, errno = %d, %s", _stream->str_stream_addr, str_conn_dir, errno, strerror(errno)); - /* after log, reset errno */ - errno = 0; } } else if (events & BEV_EVENT_EOF && rx_offset == 0 && _stream->session_type == STREAM_PROTO_SSL) @@ -1005,6 +982,25 @@ static void __stream_bev_eventcb(struct bufferevent * bev, short events, void * __stream_log_event(_stream, EVENT_LOG_CLOSE_BY_FD_EOF, conn_dir, 0, NULL); } + need_close_connection = 1; + } + + if (steering_device_is_available() && ( + (STREAM_PROTO_PLAIN == _stream->session_type && _stream->proxy_ref->traffic_steering_options.enable_steering_http) || + (STREAM_PROTO_SSL == _stream->session_type &&_stream->proxy_ref->traffic_steering_options.enable_steering_ssl))) + { + TFE_LOG_DEBUG(__STREAM_LOGGER(_stream), "decrypted traffic steering, %s %s run eventcb, %s %s", + _stream->str_stream_addr, + bev == _stream->conn_downstream->bev ? "conn_downstream" : "conn_upstream", + bev_event_to_string(events), + errno_to_string(errno) + ); + tfe_stream_destory(_stream); + return; + } + + if (need_close_connection) + { goto __close_connection; }