Close #76 修正HTTP Upgrade后没有正确Detach该连接的问题
* 原实现没有正确处理Upgrade标志位,导致连接再次进入HTTP解析流程从而无法解析,报#76所列之问题。 * 现修正,亦增加#76所示日志之五元组信息。
This commit is contained in:
@@ -503,6 +503,11 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
|
|||||||
plug_ctx->is_plugin_opened = 1;
|
plug_ctx->is_plugin_opened = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (plug_ctx->state == PLUG_STATE_DETACHED)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (p_info_iter->on_data != NULL)
|
if (p_info_iter->on_data != NULL)
|
||||||
{
|
{
|
||||||
action_tmp = p_info_iter->on_data(&_stream->head, _stream->thread_ref->thread_id,
|
action_tmp = p_info_iter->on_data(&_stream->head, _stream->thread_ref->thread_id,
|
||||||
@@ -998,7 +1003,8 @@ int __fd_ttl_option_setup(struct tfe_stream_private * _stream, evutil_socket_t f
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
TFE_STREAM_LOG_ERROR(_stream, "setsockopt(ttl = %u, fd = %d, family = %s) failed: %s",
|
TFE_STREAM_LOG_ERROR(_stream, "setsockopt(ttl = %u, fd = %d, family = %s) failed: %s",
|
||||||
__ttl, fd, __str_family, strerror(errno)); return -2;
|
__ttl, fd, __str_family, strerror(errno));
|
||||||
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ int http_plugin_init(struct tfe_proxy * proxy)
|
|||||||
plugin_ctx->gc_event_hs_private[thread_id] = gc_event;
|
plugin_ctx->gc_event_hs_private[thread_id] = gc_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin_ctx->access_logger = MESA_create_runtime_log_handle("log/http-access.log", RLOG_LV_INFO);
|
plugin_ctx->access_logger = MESA_create_runtime_log_handle("log/http.log", RLOG_LV_INFO);
|
||||||
assert(plugin_ctx->access_logger != NULL);
|
assert(plugin_ctx->access_logger != NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -419,6 +419,11 @@ enum tfe_stream_action http_connection_entry(const struct tfe_stream * stream, e
|
|||||||
return ACTION_DEFER_DATA;
|
return ACTION_DEFER_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hf_private_in->is_upgrade || hf_private_in->is_passthrough)
|
||||||
|
{
|
||||||
|
goto __passthrough;
|
||||||
|
}
|
||||||
|
|
||||||
/* Need more data, no boundary touched */
|
/* Need more data, no boundary touched */
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
@@ -431,18 +436,14 @@ enum tfe_stream_action http_connection_entry(const struct tfe_stream * stream, e
|
|||||||
return hf_private_in->stream_action;
|
return hf_private_in->stream_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == -1 && hf_private_in->is_passthrough)
|
|
||||||
{
|
|
||||||
goto __passthrough;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Some kind of error happened, write log and detach the stream */
|
/* Some kind of error happened, write log and detach the stream */
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
{
|
||||||
TFE_STREAM_LOG_ERROR(stream, "Failed at parsing stream as HTTP: %u, %s, %s",
|
TFE_LOG_ERROR(g_http_plugin->access_logger, "%s: Failed at parsing stream as HTTP, %u, %s, %s",
|
||||||
hf_private_in->parse_errno, http_errno_name(hf_private_in->parse_errno),
|
stream->str_stream_info, hf_private_in->parse_errno, http_errno_name(hf_private_in->parse_errno),
|
||||||
http_errno_description(hf_private_in->parse_errno));
|
http_errno_description(hf_private_in->parse_errno));
|
||||||
|
|
||||||
|
tfe_hexdump2file(stderr, "Failed at parsing stream as HTTP", data, (unsigned int)len);
|
||||||
goto __passthrough;
|
goto __passthrough;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user