mturk
Sat, 04 Oct 2008 23:54:17 -0700
Author: mturk Date: Sat Oct 4 23:53:20 2008 New Revision: 701751 URL: http://svn.apache.org/viewvc?rev=701751&view=rev Log: When doing get_endpoint() try to return the connected endpoints first. In send_request() we were doing exactly this when we got the endpoint, so need for double cache lock. 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=701751&r1=701750&r2=701751&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Sat Oct 4 23:53:20 2008 @@ -1363,10 +1363,8 @@ op->recoverable = JK_TRUE; /* - * First try to reuse open connections... + * First try to check open connections... */ - if (!IS_VALID_SOCKET(ae->sd)) - ajp_next_connection(ae, l); while (IS_VALID_SOCKET(ae->sd)) { int err = JK_FALSE; if (jk_is_socket_connected(ae->sd, l) == JK_FALSE) { @@ -1446,9 +1444,8 @@ ae->worker->name, err_conn, err_cping, err_send); else if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, - "(%s) all endpoints are disconnected, " - "detected by connect check (%d), cping (%d), send (%d)", - ae->worker->name, err_conn, err_cping, err_send); + "(%s) all endpoints are disconnected.", + ae->worker->name); /* Connect to the backend. */ if (ajp_connect_to_endpoint(ae, l) != JK_TRUE) { @@ -2827,13 +2824,27 @@ JK_ENTER_CS(&aw->cs, rc); if (rc) { unsigned int slot; + /* Try to find connected socket cache entry */ for (slot = 0; slot < aw->ep_cache_sz; slot++) { - if (aw->ep_cache[slot]) { + if (aw->ep_cache[slot] && + IS_VALID_SOCKET(aw->ep_cache[slot]->sd))) { ae = aw->ep_cache[slot]; aw->ep_cache[slot] = NULL; break; } } + if (!ae) { + /* No connected cache entry found. + * Use the last free one. + */ + for (slot = 0; slot < aw->ep_cache_sz; slot++) { + if (aw->ep_cache[slot]) { + ae = aw->ep_cache[slot]; + aw->ep_cache[slot] = NULL; + break; + } + } + } JK_LEAVE_CS(&aw->cs, rc); if (ae) { ae->last_access = now; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]