Author: mturk Date: Sat Mar 7 07:18:08 2009 New Revision: 751213 URL: http://svn.apache.org/viewvc?rev=751213&view=rev Log: Retun protocol error from ajp get message. This allows to make difference weather we got something from the server or the nothing at all.
Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp13.h tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp13.h URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp13.h?rev=751213&r1=751212&r2=751213&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_ajp13.h (original) +++ tomcat/connectors/trunk/jk/native/common/jk_ajp13.h Sat Mar 7 07:18:08 2009 @@ -47,6 +47,7 @@ #define JK_STATUS_ERROR (-8) #define JK_STATUS_FATAL_ERROR (-9) #define JK_REPLY_TIMEOUT (-10) +#define JK_AJP_PROTOCOL_ERROR (-11) #define AJP13_MAX_SEND_BODY_SZ (DEF_BUFFER_SZ - 6) #define AJP13_DEF_TIMEOUT (0) /* Idle timout for pooled connections */ Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c?rev=751213&r1=751212&r2=751213&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Sat Mar 7 07:18:08 2009 @@ -1177,7 +1177,7 @@ jk_shutdown_socket(ae->sd, l); ae->sd = JK_INVALID_SOCKET; JK_TRACE_EXIT(l); - return JK_FALSE; + return JK_AJP_PROTOCOL_ERROR; } } else if (ae->proto == AJP14_PROTO) { @@ -1199,7 +1199,7 @@ jk_shutdown_socket(ae->sd, l); ae->sd = JK_INVALID_SOCKET; JK_TRACE_EXIT(l); - return JK_FALSE; + return JK_AJP_PROTOCOL_ERROR; } } @@ -1216,7 +1216,7 @@ jk_shutdown_socket(ae->sd, l); ae->sd = JK_INVALID_SOCKET; JK_TRACE_EXIT(l); - return JK_FALSE; + return JK_AJP_PROTOCOL_ERROR; } msg->len = msglen; @@ -1245,16 +1245,17 @@ } ae->sd = JK_INVALID_SOCKET; JK_TRACE_EXIT(l); - return JK_FALSE; + /* Altough connection, this is effectively protocol error. + * We got the AJP header packet, but not the packet payload + */ + return JK_AJP_PROTOCOL_ERROR; } ae->endpoint.rd += (jk_uint64_t)rc; - if (ae->proto == AJP13_PROTO) { - if (JK_IS_DEBUG_LEVEL(l)) + if (JK_IS_DEBUG_LEVEL(l)) { + if (ae->proto == AJP13_PROTO) jk_dump_buff(l, JK_LOG_DEBUG, "received from ajp13", msg); - } - else if (ae->proto == AJP14_PROTO) { - if (JK_IS_DEBUG_LEVEL(l)) + else if (ae->proto == AJP14_PROTO) jk_dump_buff(l, JK_LOG_DEBUG, "received from ajp14", msg); } JK_TRACE_EXIT(l); @@ -1952,7 +1953,7 @@ } } - if (ajp_connection_tcp_get_message(p, op->reply, l) != JK_TRUE) { + if ((rc = ajp_connection_tcp_get_message(p, op->reply, l)) != JK_TRUE) { if (headeratclient == JK_FALSE) { jk_log(l, JK_LOG_ERROR, "(%s) Tomcat is down or refused connection. " @@ -2005,12 +2006,8 @@ } - /* - * we want to display the webservers error page, therefore - * we return JK_FALSE - */ JK_TRACE_EXIT(l); - return JK_FALSE; + return rc; } rc = ajp_process_callback(op->reply, op->post, p, s, l); @@ -2167,9 +2164,10 @@ * JK_STATUS_FATAL_ERROR JK_HTTP_SERVER_BUSY JK_FALSE ajp_get_reply() returns JK_STATUS_FATAL_ERROR * Only if !op->recoverable * JK_REPLY_TIMEOUT JK_HTTP_GATEWAY_TIME_OUT JK_TRUE ajp_get_reply() returns JK_REPLY_TIMEOUT - * ??? JK_FATAL_ERROR JK_HTTP_GATEWAY_TIME_OUT JK_FALSE ajp_get_reply() returns something else + * JK_AJP_PROTOCOL_ERROR JK_HTTP_GATEWAY_TIME_OUT JK_TRUE ajp_get_reply() returns JK_AJP_PROTOCOL_ERROR + * ??? JK_FATAL_ERROR JK_HTTP_GATEWAY_TIME_OUT JK_FALSE ajp_get_reply() returns something else * Only if !op->recoverable - * ??? JK_FALSE JK_HTTP_SERVER_BUSY JK_TRUE ajp_get_reply() returns JK_FALSE + * ??? JK_FALSE JK_HTTP_SERVER_BUSY JK_TRUE ajp_get_reply() returns JK_FALSE * Only if op->recoverable and no more ajp13/ajp14 direct retries * JK_TRUE JK_HTTP_OK ? OK */ @@ -2404,6 +2402,11 @@ msg = "because of response status"; rc = err; } + else if (err == JK_AJP_PROTOCOL_ERROR) { + *is_error = JK_HTTP_BAD_GATEWAY; + msg = "because of protocol error"; + rc = err; + } /* This should only be the cases err == JK_FALSE */ else { /* if we can't get reply, check if unrecoverable flag was set Modified: tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c?rev=751213&r1=751212&r2=751213&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_lb_worker.c Sat Mar 7 07:18:08 2009 @@ -1288,6 +1288,17 @@ rec->s->error_time = 0; rc = JK_FALSE; } + else if (service_stat == JK_AJP_PROTOCOL_ERROR) { + /* + * We've received the bad AJP message from the backend. + * Don't mark the node as bad. + * Failing over to another node could help. + */ + rec->s->state = JK_LB_STATE_OK; + p->states[rec->i] = JK_LB_STATE_ERROR; + rec->s->error_time = 0; + rc = JK_FALSE; + } else if (service_stat == JK_STATUS_FATAL_ERROR) { /* * Status code configured as service is down. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org