Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 1135 invoked from network); 4 Jun 2006 08:43:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Jun 2006 08:43:23 -0000 Received: (qmail 1203 invoked by uid 500); 4 Jun 2006 08:43:18 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 851 invoked by uid 500); 4 Jun 2006 08:43:17 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 840 invoked by uid 500); 4 Jun 2006 08:43:16 -0000 Delivered-To: apmail-jakarta-tomcat-dev@jakarta.apache.org Received: (qmail 835 invoked by uid 99); 4 Jun 2006 08:43:16 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Jun 2006 01:43:16 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Jun 2006 01:43:16 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id C7C511A983A; Sun, 4 Jun 2006 01:42:55 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r411537 - /tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Date: Sun, 04 Jun 2006 08:42:55 -0000 To: tomcat-dev@jakarta.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060604084255.C7C511A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: mturk Date: Sun Jun 4 01:42:54 2006 New Revision: 411537 URL: http://svn.apache.org/viewvc?rev=411537&view=rev Log: 1. Use close instead of shutdown when recycling cache slots. The connection does not have any pending data in that case. 2. Implement the mincache (it was always 1). 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=411537&r1=411536&r2=411537&view=diff ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Sun Jun 4 01:42:54 2006 @@ -692,15 +692,14 @@ return JK_TRUE; } - /* - * Reset the endpoint (clean buf) + * Reset the endpoint (clean buf and close socket) */ static void ajp_reset_endpoint(ajp_endpoint_t * ae, jk_logger_t *l) { if (ae->sd > 0 && !ae->reuse) { - jk_shutdown_socket(ae->sd); + jk_close_socket(ae->sd); if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, "reset socket with sd = %d", ae->sd); @@ -710,7 +709,7 @@ } /* - * Close the endpoint (clean buf and close socket) + * Close the endpoint (close pool and close socket) */ void ajp_close_endpoint(ajp_endpoint_t * ae, jk_logger_t *l) @@ -1857,8 +1856,8 @@ } if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, - "setting connection cache size to %d", - p->ep_cache_sz); + "setting connection cache size to %u with min %u", + p->ep_cache_sz, p->ep_mincache_sz); for (i = 0; i < p->ep_cache_sz; i++) { p->ep_cache[i] = (ajp_endpoint_t *)calloc(1, sizeof(ajp_endpoint_t)); if (!p->ep_cache[i]) { @@ -1899,6 +1898,8 @@ if (pThis && pThis->worker_private) { ajp_worker_t *p = pThis->worker_private; p->ep_cache_sz = jk_get_worker_cache_size(props, p->name, cache); + p->ep_mincache_sz = jk_get_worker_cache_size_min(props, p->name, + cache / 2); p->socket_timeout = jk_get_worker_socket_timeout(props, p->name, AJP_DEF_SOCKET_TIMEOUT); @@ -1989,7 +1990,6 @@ */ p->secret = jk_get_worker_secret(props, p->name); - p->ep_mincache_sz = 1; /* Initialize cache slots */ JK_INIT_CS(&(p->cs), rc); if (!rc) { @@ -2001,7 +2001,7 @@ } if (!ajp_create_endpoint_cache(p, proto, l)) { jk_log(l, JK_LOG_ERROR, - "allocating ep_cache of size %d", + "allocating ep_cache of size %u", p->ep_cache_sz); JK_TRACE_EXIT(l); return JK_FALSE; @@ -2026,7 +2026,7 @@ if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, - "up to %d endpoints to close", + "up to %u endpoints to close", aw->ep_cache_sz); for (i = 0; i < aw->ep_cache_sz; i++) { @@ -2088,7 +2088,7 @@ if (i >= 0) { if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, - "recycling connection cache slot=%d for worker %s", + "recycling connection cache slot=%u for worker %s", i, p->worker->name); JK_TRACE_EXIT(l); return JK_TRUE; @@ -2097,14 +2097,14 @@ * there is always free empty cache slot */ jk_log(l, JK_LOG_ERROR, - "could not find empty cache slot from %d for worker %s", + "could not find empty cache slot from %u for worker %s", w->ep_cache_sz, w->name); JK_TRACE_EXIT(l); return JK_FALSE; } jk_log(l, JK_LOG_ERROR, - "Could not lock mutex errno=%d", errno); + "locking thread with errno=%d", errno); JK_TRACE_EXIT(l); return JK_FALSE; } @@ -2145,14 +2145,14 @@ JK_LEAVE_CS(&aw->cs, rc); if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, - "acquired connection cache slot=%d", + "acquired connection cache slot=%u", slot); JK_TRACE_EXIT(l); return JK_TRUE; } else { jk_log(l, JK_LOG_WARNING, - "Unable to get the free endpoint for worker %s from %d slots", + "Unable to get the free endpoint for worker %s from %u slots", aw->name, aw->ep_cache_sz); } JK_LEAVE_CS(&aw->cs, rc); @@ -2210,15 +2210,24 @@ ajp_reset_endpoint(aw->ep_cache[i], l); if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, - "cleaning cache slot=%d elapsed %u in %d", + "cleaning cache slot=%u elapsed %d in %d", i, elapsed, (int)(difftime(time(NULL), rt))); } } + if (n > aw->ep_mincache_sz) { + if (JK_IS_DEBUG_LEVEL(l)) { + jk_log(l, JK_LOG_DEBUG, + "reached cache min size %u from %u cache slots", + aw->ep_mincache_sz, aw->ep_cache_sz); + } + break; + } } if (JK_IS_DEBUG_LEVEL(l)) jk_log(l, JK_LOG_DEBUG, - "recycled %u sockets in %d seconds", - n, (int)(difftime(time(NULL), now))); + "recycled %u sockets in %d seconds from %u cache slots", + n, (int)(difftime(time(NULL), now)), + aw->ep_cache_sz); JK_LEAVE_CS(&aw->cs, rc); JK_TRACE_EXIT(l); return JK_TRUE; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org