From: Rainer Jung Date: Sat, 30 Jul 2011 10:54:04 +0000 (+0000) Subject: Make AJP trace messages a bit less cryptic. X-Git-Tag: 2.3.14^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a7fe66131cb3dc50ee468baaa5870ab537622d29;p=apache Make AJP trace messages a bit less cryptic. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1152450 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/ajp.h b/modules/proxy/ajp.h index ae64f817cf..6bba231178 100644 --- a/modules/proxy/ajp.h +++ b/modules/proxy/ajp.h @@ -491,6 +491,15 @@ apr_status_t ajp_parse_reuse(request_rec *r, ajp_msg_t *msg, apr_status_t ajp_handle_cping_cpong(apr_socket_t *sock, request_rec *r, apr_interval_time_t timeout); + + +/** + * Convert numeric message type into string + * @param type AJP message type + * @return AJP message type as a string + */ +const char *ajp_type_str(int type); + /** @} */ #endif /* AJP_H */ diff --git a/modules/proxy/ajp_header.c b/modules/proxy/ajp_header.c index 67eb91cdae..7a1aaddbe1 100644 --- a/modules/proxy/ajp_header.c +++ b/modules/proxy/ajp_header.c @@ -683,7 +683,8 @@ apr_status_t ajp_read_header(apr_socket_t *sock, } rc = ajp_msg_peek_uint8(*msg, &result); ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, r->server, - "ajp_read_header: ajp_ilink_received 0x%02x", result); + "ajp_read_header: ajp_ilink_received %s (0x%02x)", + ajp_type_str(result), result); return APR_SUCCESS; } @@ -693,7 +694,8 @@ int ajp_parse_type(request_rec *r, ajp_msg_t *msg) apr_byte_t result; ajp_msg_peek_uint8(msg, &result); ap_log_error(APLOG_MARK, APLOG_TRACE6, 0, r->server, - "ajp_parse_type: got 0x%02x", result); + "ajp_parse_type: got %s (0x%02x)", + ajp_type_str(result), result); return (int) result; } @@ -712,8 +714,9 @@ apr_status_t ajp_parse_header(request_rec *r, proxy_dir_conf *conf, } if (result != CMD_AJP13_SEND_HEADERS) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "ajp_parse_headers: wrong type 0x%02x expecting 0x%02x", - result, CMD_AJP13_SEND_HEADERS); + "ajp_parse_headers: wrong type %s (0x%02x) expecting %s (0x%02x)", + ajp_type_str(result), result, + ajp_type_str(CMD_AJP13_SEND_HEADERS), CMD_AJP13_SEND_HEADERS); return AJP_EBAD_HEADER; } return ajp_unmarshal_response(msg, r, conf); @@ -735,8 +738,9 @@ apr_status_t ajp_parse_data(request_rec *r, ajp_msg_t *msg, } if (result != CMD_AJP13_SEND_BODY_CHUNK) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "ajp_parse_data: wrong type 0x%02x expecting 0x%02x", - result, CMD_AJP13_SEND_BODY_CHUNK); + "ajp_parse_data: wrong type %s (0x%02x) expecting %s (0x%02x)", + ajp_type_str(result), result, + ajp_type_str(CMD_AJP13_SEND_BODY_CHUNK), CMD_AJP13_SEND_BODY_CHUNK); return AJP_EBAD_HEADER; } rc = ajp_msg_get_uint16(msg, len); @@ -779,8 +783,9 @@ apr_status_t ajp_parse_reuse(request_rec *r, ajp_msg_t *msg, } if (result != CMD_AJP13_END_RESPONSE) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, - "ajp_parse_reuse: wrong type 0x%02x expecting 0x%02x", - result, CMD_AJP13_END_RESPONSE); + "ajp_parse_reuse: wrong type %s (0x%02x) expecting %s (0x%02x)", + ajp_type_str(result), result, + ajp_type_str(CMD_AJP13_END_RESPONSE), CMD_AJP13_END_RESPONSE); return AJP_EBAD_HEADER; } return ajp_msg_get_uint8(msg, reuse); diff --git a/modules/proxy/ajp_utils.c b/modules/proxy/ajp_utils.c index d04a39f7ea..b6cea731eb 100644 --- a/modules/proxy/ajp_utils.c +++ b/modules/proxy/ajp_utils.c @@ -105,3 +105,31 @@ cleanup: "ajp_handle_cping_cpong: Done"); return rv; } + + +#define case_to_str(x) case CMD_AJP13_##x:\ + return #x;\ + break; + +/**ยท + * Convert numeric message type into string + * @param type AJP message type + * @return AJP message type as a string + */ +const char *ajp_type_str(int type) +{ + switch (type) { + case_to_str(FORWARD_REQUEST) + case_to_str(SEND_BODY_CHUNK) + case_to_str(SEND_HEADERS) + case_to_str(END_RESPONSE) + case_to_str(GET_BODY_CHUNK) + case_to_str(SHUTDOWN) + case_to_str(PING) + case_to_str(CPONG) + case_to_str(CPING) + default: + return "CMD_AJP13_UNKNOWN"; + } + +}