Author: mturk Date: Fri Jul 7 23:44:25 2006 New Revision: 420058 URL: http://svn.apache.org/viewvc?rev=420058&view=rev Log: If all endpoints are dead or closed by the Tomcat, then try to reconnect if timeouts are set. This fixes the cases when connect_timeout is set for load balancer.
Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c 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=420058&r1=420057&r2=420058&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Fri Jul 7 23:44:25 2006 @@ -1218,22 +1218,29 @@ * If we failed to reuse a connection, try to reconnect. */ if (ae->sd < 0) { - - if (err) { + /* If we the previous connection was in error + * try to reconnect only if timeouts are set + */ + if (err && ae->worker->connect_timeout == 0 && + ae->worker->socket_timeout == 0) { /* XXX: If err is set, the tomcat is either dead or disconnected */ jk_log(l, JK_LOG_INFO, "All endpoints are disconnected or dead"); JK_TRACE_EXIT(l); return JK_FALSE; } - /* no need to handle cping/cpong here since it should be at connection time */ - + /* Connect to the backend. + * This can be either uninitalized connection or a reconnect. + */ if (ajp_connect_to_endpoint(ae, l) == JK_TRUE) { /* * After we are connected, each error that we are going to * have is probably unrecoverable */ if (ajp_connection_tcp_send_message(ae, op->request, l) != JK_TRUE) { + /* Close the socket if unable to send request */ + jk_close_socket(ae->sd); + ae->sd = -1; jk_log(l, JK_LOG_INFO, "Error sending request on a fresh connection"); JK_TRACE_EXIT(l); @@ -1245,7 +1252,7 @@ jk_close_socket(ae->sd); ae->sd = -1; jk_log(l, JK_LOG_INFO, - "Error connecting to the Tomcat process."); + "Error connecting to the backend server."); JK_TRACE_EXIT(l); return JK_FALSE; } @@ -1273,6 +1280,9 @@ postlen = op->post->len; if (postlen > AJP_HEADER_LEN) { if (ajp_connection_tcp_send_message(ae, op->post, l) != JK_TRUE) { + /* Close the socket if unable to send request */ + jk_close_socket(ae->sd); + ae->sd = -1; jk_log(l, JK_LOG_ERROR, "Error resending request body (%d)", postlen); JK_TRACE_EXIT(l); @@ -1290,6 +1300,9 @@ if (postlen > AJP_HEADER_LEN) { if (ajp_connection_tcp_send_message(ae, s->reco_buf, l) != JK_TRUE) { + /* Close the socket if unable to send request */ + jk_close_socket(ae->sd); + ae->sd = -1; jk_log(l, JK_LOG_ERROR, "Error resending request body (lb mode) (%d)", postlen); @@ -1337,6 +1350,9 @@ s->content_read = len; if (ajp_connection_tcp_send_message(ae, op->post, l) != JK_TRUE) { + /* Close the socket if unable to send request */ + jk_close_socket(ae->sd); + ae->sd = -1; jk_log(l, JK_LOG_ERROR, "Error sending request body"); JK_TRACE_EXIT(l); return JK_FALSE; @@ -2246,6 +2262,3 @@ JK_TRACE_EXIT(l); return JK_FALSE; } - - - --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]