You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Hieu Phan Thanh <hi...@Cybersoft-VN.com> on 2006/11/01 15:34:41 UTC

RE: [MINA 1.0.0] Could not stop listening on Port

Hi, now I often encounter this problem.

1) Firstly, 
- I created an Instance of SocketAcceptor and do bind more than 1 data
port to that SocketAcceptor. 
- There are 3 data senders will connect to my software and send date
with huge speed.
- After awhile (5 mins), I call the unbindAll() to stop all listening
data port (after adding some log messages in the unbindAll() method):
	+ the 1st port is unbound successfully.
	+ the 2nd port: the unbind could not successfully due to the
"wait()" command is locked forever (I m not sure the reason why).
=> I think that it is really the MINA bug. Do I miss anything?
One more thing, if there is no connection to any port => the unbindAll()
is always returned.

2) I have to try to create amount of SocketAcceptor (each instance just
is bound only one data port).
- Execute the test scenario above again, the unbindAll() is returned ok.

I could not upload my software because of IT protection policy.
I hope that I could make a simple app to reproduce this kind of problem
so that the MINA community would solve this one completely.

Thanks & best regards,
Hieu Phan.


> -----Original Message-----
> From: Hieu Phan Thanh [mailto:hieupt@Cybersoft-VN.com]
> Sent: Wednesday, November 01, 2006 4:40 PM
> To: mina-dev@directory.apache.org
> Subject: RE: [MINA 0.8.3] Could not stop listening on Port
> 
> Hi all you guys,
> 
> To solve this problem, I think that we should review the source code
> more carefully.
> 
> I don't know exactly.
> But IMO in the "unbind" method we have the "request.wait()" here.
> What will happened if the "notify" thread is happened before the
"wait"
> thread? The "unbind" method will be never returned?
> 
> --BEGIN--
> 	synchronized( request )
>         {
>             while( !request.done )
>             {
>                 try
>                 {
>                     request.wait();
>                 }
>                 catch( InterruptedException e )
>                 {
>                     ExceptionMonitor.getInstance().exceptionCaught( e
);
>                 }
>             }
>         }
> --END--
> 
> Thanks & best regards,
> Hieu Phan.


Re: [MINA 1.0.0] Could not stop listening on Port

Posted by peter royal <pr...@apache.org>.
On Nov 6, 2006, at 5:07 PM, Trustin Lee wrote:
> Then request.done is set to true, so we don't call wait() at all.   
> Please
> search for 'request.done = true' in the source code.  It is also in a
> synchronized block.  I can't think of a scenario this code blocks  
> forever.

it should probably be declared as voilatile, in order to prevent  
threads viewing a stale value

> We can use CountDownLatch, but the initial count will always be 1.   
> What is
> the advantage in using it?

yes, the initial count will be one. by using a CountDownLatch,  
synchronization is encapsulated in the Latch. less error prone, imo,  
as the CountDownLatch is from the JDK and well tested :)

-pete


-- 
proyal@apache.org - http://fotap.org/~osi




Re: [MINA 1.0.0] Could not stop listening on Port

Posted by Trustin Lee <tr...@gmail.com>.
On 11/7/06, peter royal <pr...@apache.org> wrote:
>
> >> To solve this problem, I think that we should review the source code
> >> more carefully.
> >>
> >> I don't know exactly.
> >> But IMO in the "unbind" method we have the "request.wait()" here.
> >> What will happened if the "notify" thread is happened before the
> > "wait"
> >> thread? The "unbind" method will be never returned?


Then request.done is set to true, so we don't call wait() at all.  Please
search for 'request.done = true' in the source code.  It is also in a
synchronized block.  I can't think of a scenario this code blocks forever.

>>
> >> --BEGIN--
> >>      synchronized( request )
> >>         {
> >>             while( !request.done )
> >>             {
> >>                 try
> >>                 {
> >>                     request.wait();
> >>                 }
> >>                 catch( InterruptedException e )
> >>                 {
> >>                     ExceptionMonitor.getInstance().exceptionCaught( e
> > );
> >>                 }
> >>             }
> >>         }
> >> --END--
>
> This should be fixed in the 1.2 branch, as it now uses a
> CountDownLatch to indicate completion.


We can use CountDownLatch, but the initial count will always be 1.  What is
the advantage in using it?

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Re: [MINA 1.0.0] Could not stop listening on Port

Posted by peter royal <pr...@apache.org>.
>> To solve this problem, I think that we should review the source code
>> more carefully.
>>
>> I don't know exactly.
>> But IMO in the "unbind" method we have the "request.wait()" here.
>> What will happened if the "notify" thread is happened before the
> "wait"
>> thread? The "unbind" method will be never returned?
>>
>> --BEGIN--
>> 	synchronized( request )
>>         {
>>             while( !request.done )
>>             {
>>                 try
>>                 {
>>                     request.wait();
>>                 }
>>                 catch( InterruptedException e )
>>                 {
>>                     ExceptionMonitor.getInstance().exceptionCaught( e
> );
>>                 }
>>             }
>>         }
>> --END--

This should be fixed in the 1.2 branch, as it now uses a  
CountDownLatch to indicate completion.
-pete


-- 
proyal@apache.org - http://fotap.org/~osi