On Mon, Feb 23, 2009 at 10:28 AM, Maarten Bosteels
<[email protected]> wrote:
> On Wed, Feb 18, 2009 at 11:04 PM, Emmanuel Lecharny 
> <[email protected]>wrote:
>
>>
>>  Logically, one thread is associated with one session, that's the idea.
>>>> If you have more than one thread writing data in one single session,
>>>> then yes, you may have problems...
>>>>
>>>>
>>>
>>>
>>>
>>> Emmanuel, I don't understand what you are saying.
>>>
>>>
>> What I mean is that once the server receive a message, it selects a thread
>> to handle this message within its session. And if you have more than one
>> thread writing in a session, it may not be thread safe.
>
>
> I strongly disagree. IoSession is declared to be thread-safe. See the
> javadoc [1]:

I have to go back to the code. I have been away from it since last
november, and it does not help to undertsand what's going on... My
bad.
>> I think that the key is how you enforce this simultaneous writing. Now, if
>> you consider that the server is reacting to incoming messages, then there is
>> only one thread writing in a session, as this thread has been selected to
>> deal with the incoming message.
>>
>> If your handler spawn more than one thread, which all write something, I
>> have no idea how the server can behave. This is something I never thought
>> could be done, or worth to be done. May be it's simply not supported...
>
>
> It has always been supported. And I think we definitely should keep
> supporting it.
>
> What you are saying is "only call ioSession.write from within your
> messageReceived handler, and only on the session that generated the event".
> It's the first time I see claims like that.
>
> This rule would make it (nearly) impossible to write a chat-server.
> I checked our chat-server example [2] and according to your rules it's
> broken.
>
> The broadcast method syncronizes on the private member "sessions" but not on
> the individual IoSession instances.
>
> Besides, I haven't see doco saying on what we should syncrhonize when
> writing simultanously to the same session from mulltiple threads.
>
> I think this it's fundamental that all MINA committers agree on whether
> IoSession should be thread-safe.
> And when the answer is "no" we should fix the documentation.

You're right. I will have a look at the problem this week. Anyway,
it's time to clear the bug list, the 2.0-RC1 has to get out.

Thanks Maarten !

-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Reply via email to