You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2006/09/16 16:13:18 UTC
DO NOT REPLY [Bug 40525] New: - Native library causes 100% cpu use when idle
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
DO NOT REPLY [Bug 40525] - Native library causes 100% cpu use when idle
Posted by bu...@apache.org.
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
remm@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gturski@interia.pl
------- Additional Comments From remm@apache.org 2006-09-27 20:31 -------
*** Bug 40606 has been marked as a duplicate of this bug. ***
--
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
DO NOT REPLY [Bug 40525] - Native library causes 100% cpu use when idle
Posted by bu...@apache.org.
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
mturk@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
------- Additional Comments From mturk@apache.org 2006-09-28 07:38 -------
Fixed in the SVN trunk, although the patch aplied is slightly different.
--
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
DO NOT REPLY [Bug 40525] - Native library causes 100% cpu use when idle
Posted by bu...@apache.org.
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
rainer.jung@kippdata.de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |CLOSED
Component|Native:JK |Unknown
------- Additional Comments From rainer.jung@kippdata.de 2008-01-01 16:48 -------
Removing Native:JK component, because this issue belongs to tcnative, which
seems to not have a component value.
Also moving from resolved to closed.
--
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
DO NOT REPLY [Bug 40525] - Native library causes 100% cpu use when idle
Posted by bu...@apache.org.
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
------- Additional Comments From Tom.Donovan@acm.org 2006-09-18 23:56 -------
(In reply to comment #0)
The patch in my original comment is incorrect. It does not preserve the timeout
when there is no socket timeout. Apologies!
Here is a corrected patch:
Index: jni/native/src/poll.c
===================================================================
--- jni/native/src/poll.c (revision 446772)
+++ jni/native/src/poll.c (working copy)
@@ -263,13 +263,16 @@
/* 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) {
- ptime = 0;
- break;
- }
- else {
- ptime = TCN_MIN(p->max_ttl - t, ptime);
- }
+ if (p->max_ttl > 0)
+ {
+ if (t >= p->max_ttl) {
+ ptime = 0;
+ break;
+ }
+ else {
+ ptime = TCN_MIN(p->max_ttl - t, ptime);
+ }
+ }
}
}
for (;;) {
--
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