Openfire

MINA's SessionCreated or SessionOpened?

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: 3.7.2
  • Component/s: None
  • Labels:
    None
  • Acceptance Test - Add?:
    No

Description

The IoHandler implementation of Apache MINA is a event listener interface. It has two methods that are invoked in relation to session creation:

void sessionCreated(IoSession session)

Invoked from an I/O processor thread when a new connection has been created. Because this method is supposed to be called from the same thread that handles I/O of multiple sessions, please implement this method to perform tasks that consumes minimal amount of time such as socket parameter and user-defined session attribute initialization.

void sessionOpened(IoSession session)

Invoked when a connection has been opened. This method is invoked after #sessionCreated(IoSession). The biggest difference from #sessionCreated(IoSession) is that it's invoked from other thread than an I/O processor thread once thread modesl is configured properly.

Openfire currently uses sessionOpened in the ConnectionHandler class. Although this should improve performance of the I/O processor threads, it could also introduce concurrency related problems. From the javadocs, I can't determine if it is guaranteed, for example, that other events are invoked only after sessionOpened has returned.

ConnectionHandler is used to initialize session attributes - exactly what is appropiate in the sessionCreated method, according to its javadoc.

I've had several reports of various problems that occur just after a user logs on. I have never been able to track down these issues. The explanation above could be a cause of these kind of problems.

We should consider using sessionCreated instead of sessionOpened in Openfires ConnectionHandler to prevent concurrency-related problems.

Activity

Hide
Guus der Kinderen added a comment -

I'm postponing this to the next release. The 3.7.0 beta went out without this - seems like a odd change to make after the beta is out. Let's do this for a future beta.

Show
Guus der Kinderen added a comment - I'm postponing this to the next release. The 3.7.0 beta went out without this - seems like a odd change to make after the beta is out. Let's do this for a future beta.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: