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 37356] - Tomcat does not invalidate sessions after session-timeout period has passed.
Date Fri, 10 Mar 2006 11:15:54 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=37356>.
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=37356





------- Additional Comments From tm@allocation.net  2006-03-10 11:15 -------
Proposed patch:

in org.apache.catalina.session.StandardSession
 line 284 (tomcat 5.0.28)

    /**
     * The access count for this session.
     */
    protected transient int accessCount = 0;

has to be replaced by 

    /**
     * The access count for this session.
     */
    protected volatile transient int accessCount = 0;

Explanation:
The expression accessCount++ is not thread-safe because each thread may hold a
local copy of the variable which does not have to be synchronized with main
memory immediately.
The volatile keyword forces this synchronization.

See the discussion on 
http://forum.java.sun.com/thread.jspa?threadID=604831&start=30&tstart=0

[quote]
2) Local vs. main mem: Threads have--or can have--their own local copies of
shared variables. When T1 writes a value to a variable, if the variable is not
volatile and there's no syncing, that new value may live only in T1's local copy
and may never get written to main mem, which means other threads may never see
that new value. Entering and leaving sync blocks forces a reconciliation between
the thread's local memory and main mem. Declaring a variable volatile forces
every read and write of that variable to go to main mem.
[end quote]

Another solution would be to synchronize the code segments.

I have to apologize for my claim that ++ and -- were atomic for int datatypes. 
This seems to be only true for single-CPU systems (without hyperThreading).

-- 
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