]> granicus.if.org Git - apache/commitdiff
Make AJP trace messages a bit less cryptic.
authorRainer Jung <rjung@apache.org>
Sat, 30 Jul 2011 10:54:04 +0000 (10:54 +0000)
committerRainer Jung <rjung@apache.org>
Sat, 30 Jul 2011 10:54:04 +0000 (10:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1152450 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/ajp.h
modules/proxy/ajp_header.c
modules/proxy/ajp_utils.c

index ae64f817cf4176eabf42c9d3ac1088e3627c4497..6bba231178b91baf91520ed01dc05dfac9133b23 100644 (file)
@@ -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 */
index 67eb91cdae8204cfa40547a7a8956cb941082ba2..7a1aaddbe1e582ab0de0247d3b101b4ae4f36980 100644 (file)
@@ -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);
index d04a39f7ea4da19fb4d3e9c007da622d56a43c0a..b6cea731eb5028e8addabb6dbcf43fb69920f9a7 100644 (file)
@@ -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";
+    }
+
+}