Just a shot in the dark here, but what if:

  1. We synchronize on 'session' for the bulk of the 'for' loop.
  2. We make StandardSession.access() synchronized
         * I'd really like to avoid (2), but I don't see a really good
           alternative.
  3. We fix the other FIXME regarding LRU by creating a treemap sorting
     by access time and then just walk over values().
         * I'd really like to actually just keep a doubly linked list
           in the manager and bump sessions to the front of this in
           StandardSession, but I'm not sure if doing this in access()
           would suffice.

Suggestion would be appreciated!

--
Jess Holle

Jess Holle wrote:

I have dire need to use PersistentManager, which is experimental at this time.

Looking in the source, I note 2 "FIXME" comments -- one of which seems to clearly indicate a race condition. It actually occurs twice (though the comment only occurs once) but the code in both cases looks similar to:

            // Swap out all sessions idle longer than maxIdleSwap
            // FIXME: What's preventing us from mangling a session during
            // a request?
            if (maxIdleSwap >= 0) {
                for (int i = 0; i < sessions.length; i++) {
                    StandardSession session = (StandardSession)
    sessions[i];
                    if (!session.isValid())
                        continue;
                    int timeIdle = // Truncate, do not round up
                        (int) ((timeNow -
    session.getLastAccessedTime()) / 1000L);
                    if (timeIdle > maxIdleSwap && timeIdle >
    minIdleSwap) {
                        if (log.isDebugEnabled())
                            log.debug(sm.getString
                                ("persistentManager.swapMaxIdle",
                                 session.getId(), new Integer(timeIdle)));
                        try {
                            swapOut(session);
                        } catch (IOException e) {
                            ;   // This is logged in writeSession()
                        }
                    }
                }
            }

Does anyone have any brilliant ideas/suggestions on how this condition should be resolved? I'm digging around, but my experience with all of the pieces involved is rather limited.

--
Jess Holle




Reply via email to