Author: markt
Date: Sun Apr 11 13:54:51 2010
New Revision: 932904
URL: http://svn.apache.org/viewvc?rev=932904&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48790
Make maxActive thread safe. I almost marked this as WONTFIX. Only the fact that
it is, technically, a bug stopped me.
Simplified patch based on kkolinko's patch
Modified:
tomcat/tc6.0.x/trunk/STATUS.txt
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/ManagerBase.java
tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=932904&r1=932903&r2=932904&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Sun Apr 11 13:54:51 2010
@@ -119,20 +119,6 @@ PATCHES PROPOSED TO BACKPORT:
+1: markt, kkolinko
-1:
-* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48790
- Make maxActive thread safe. I almost marked this as WONTFIX. Only the fact
- that it is, technically, a bug stopped me.
- Simplified patch based on kkolinko's patch below
- http://svn.apache.org/viewvc?view=revision&revision=927037
- +1: markt, kkolinko, rjung
- -1:
-
- I think it can be done more simply:
- http://people.apache.org/~kkolinko/patches/2010-03-16_tc6_bug48790.patch
- +1: kkolinko
- -1: markt - setMaxActive() also needs to use the update lock
- I'll revert my patch above and propose a new one based on this
-
* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48793
Make catalina.sh more robust to different return values on different
platforms
Patch provided by Thomas GL
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java?rev=932904&r1=932903&r2=932904&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java
Sun Apr 11 13:54:51 2010
@@ -1204,7 +1204,7 @@ public class DeltaManager extends Cluste
rejectedSessions = 0 ;
sessionReplaceCounter = 0 ;
counterNoStateTransfered = 0 ;
- maxActive = getActiveSessions() ;
+ setMaxActive(getActiveSessions());
sessionCounter = getActiveSessions() ;
counterReceive_EVT_ALL_SESSION_DATA = 0;
counterReceive_EVT_GET_ALL_SESSIONS = 0;
Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/ManagerBase.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/ManagerBase.java?rev=932904&r1=932903&r2=932904&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/ManagerBase.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/session/ManagerBase.java Sun
Apr 11 13:54:51 2010
@@ -180,7 +180,9 @@ public abstract class ManagerBase implem
// Number of sessions created by this manager
protected int sessionCounter=0;
- protected int maxActive=0;
+ protected volatile int maxActive=0;
+
+ private final Object maxActiveUpdateLock = new Object();
// number of duplicated session ids - anything >0 means we have problems
protected int duplicates=0;
@@ -765,7 +767,11 @@ public abstract class ManagerBase implem
sessions.put(session.getIdInternal(), session);
int size = sessions.size();
if( size > maxActive ) {
- maxActive = size;
+ synchronized(maxActiveUpdateLock) {
+ if( size > maxActive ) {
+ maxActive = size;
+ }
+ }
}
}
@@ -1107,7 +1113,9 @@ public abstract class ManagerBase implem
public void setMaxActive(int maxActive) {
- this.maxActive = maxActive;
+ synchronized (maxActiveUpdateLock) {
+ this.maxActive = maxActive;
+ }
}
Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=932904&r1=932903&r2=932904&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Sun Apr 11 13:54:51 2010
@@ -64,6 +64,10 @@
serving where multiple threads could try to use the the same
InputStream. (markt)
</fix>
+ <fix>
+ <bug>48790</bug>: Fix thread safety issue in the count of the maximum
+ number of active session. (markt/kkolinko)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]