增加Per Stream摘要日志功能,修正TCP上、下游连接不能联动关闭的问题。
* 增加Per Stream摘要日志功能,记录连接四元组、HTTP URL等关键信息,便于调试; * 原实现在上游连接关闭时,不能关闭下游连接(反之亦然),现修正。
This commit is contained in:
@@ -560,7 +560,36 @@ struct http_session_private * hs_private_create(struct http_connection_private *
|
||||
return __hs_private;
|
||||
}
|
||||
|
||||
void __write_access_log(struct http_session_private * hs_private)
|
||||
{
|
||||
/* Prepare to write session access log */
|
||||
char __access_log[TFE_STRING_MAX];
|
||||
size_t __offset = 0;
|
||||
|
||||
/* Request */
|
||||
struct http_half_private * request = to_hf_request_private(hs_private);
|
||||
/* Response */
|
||||
struct http_half_private * response = to_hf_request_private(hs_private);
|
||||
/* Req-Public */
|
||||
struct tfe_http_req_spec * req_spec = request ? &to_hf_public(request)->req_spec : NULL;
|
||||
/* Resp-Public */
|
||||
struct tfe_http_resp_spec * resp_spec = response ? &to_hf_public(response)->resp_spec : NULL;
|
||||
|
||||
/* Method */
|
||||
const char * __str_method = req_spec ? http_std_method_to_string(req_spec->method) : "-";
|
||||
__offset += snprintf(__access_log + __offset, sizeof(__access_log) - __offset, "%s ", __str_method);
|
||||
|
||||
/* URL */
|
||||
const char * __str_url = req_spec ? req_spec->url : "-";
|
||||
__offset += snprintf(__access_log + __offset, sizeof(__access_log) - __offset, "%s ", __str_url);
|
||||
|
||||
const struct tfe_stream * stream = hs_private->hc_private->stream;
|
||||
tfe_stream_write_log(stream, RLOG_LV_INFO, "%s", __access_log);
|
||||
(void)resp_spec;
|
||||
}
|
||||
|
||||
void hs_private_destory(struct http_session_private * hs_private)
|
||||
{
|
||||
__write_access_log(hs_private);
|
||||
free(hs_private);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user