tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 40525] New: - Native library causes 100% cpu use when idle
Date Sat, 16 Sep 2006 14:13:18 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40525>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40525

           Summary: Native library causes 100% cpu use when idle
           Product: Tomcat 5
           Version: 5.5.17
          Platform: PC
        OS/Version: Windows 2000
            Status: NEW
          Keywords: PatchAvailable
          Severity: normal
          Priority: P3
         Component: Native:JK
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: Tom.Donovan@acm.org


The jni native method poll() in poll.c does not check if the socket has no
timeout (i.e. it does not check if max_ttl is negative) before adjusting the
timeout passed to apr_pollset_poll().  

The timeout passed to apr_pollset_poll() is in the variable 'ptime'.  The
current code sets ptime to zero when there is a valid timeout (usually 2000ms)
and no socket timeout (usually -1000).

These values are common because AprEndpoint.java defaults to pollTime=2000 ms
and soTimeout=-1 sec (which gets adjusted to -1000 ms).
    
When a zero timeout is passed to apr_pollset_poll(), it is passed along to the 
native select() as a zero timeval which causes select() to return immediately
instead of blocking. A negative value should be passed to apr_pollset_poll() for
an infinite timeout, but I don't think that's what we want here.

The observed result is 100% cpu use when Tomcat is idle because calls to poll()
are made continuously. These calls return immediately.

The solution is to recognize when max_ttl is negative, and if so; do not use it 
to adjust the 'ptime' variable passed as an argument to poll().  Here is a patch 
for http://svn.apache.org/repos/asf/tomcat/connectors/trunk/.

Index: jni/native/src/poll.c
===================================================================
--- jni/native/src/poll.c	(revision 446772)
+++ jni/native/src/poll.c	(working copy)
@@ -263,7 +263,7 @@
         /* Find the minimum timeout */
         for (i = 0; i < p->nelts; i++) {
             apr_interval_time_t t = now - p->socket_ttl[i];
-            if (t >= p->max_ttl) {
+            if (p->max_ttl > 0 && t >= p->max_ttl) {
                 ptime = 0;
                 break;
             }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message