users@grizzly.java.net

Re: Doubts about SelectionKey expire

From: Luiz Hamilton R L Soares <luizhamilton29_at_yahoo.com.br>
Date: Wed, 26 Sep 2007 09:04:18 -0300 (ART)

Jeanfrancois,
   
  I´ve tried it and it is working fine.
   
  Thanks for your help,
   
  Luiz

Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM> escreveu:
  Hi Luiz,

I've just committed a fix. Can you try it and let me know if that fixed
your problem?

Thanks

-- Jeanfrancois


Jeanfrancois Arcand wrote:
> Hi Luiz,
>
> Luiz Hamilton R L Soares wrote:
>> Hi,
>>
>> First of all, thanks for the help about Async TCP Server. I´ve
>> implemented it, but my server was losing performance, so I decided to
>> disable it.
>>
>> Well, now I have another doubt.
>>
>> I´m facing some problem with idle connections. I´ve set up timeout to
>> five minutes and it was cancelling one SelectionKey each 5 minutes.
>> And after some time, I have more than 1.000 idle connections and only
>> one is cancelled every 5 minutes.
>>
>> I looked the source code of DefaultSelectionKeyHandler and I´ve found
>> a method called expire(Iterator iterator) . I changed
>> one line:
>> nextKeysExpiration = currentTime + timeout;
>> to
>> nextKeysExpiration = currentTime + 20*1000L;
>> Now it tries to cancel a SelectionKey every 20 seconds and my timeout
>> is still 5 minutes.
>>
>> That was working fine, but after a while, keys that is more than 5
>> hours idle was not getting cancelled. So I´ve changed another line:
>>
>> if (currentTime < nextKeysExpiration) {
>> return;
>> }
>>
>> to
>> if (currentTime < nextKeysExpiration) {
>> //return;
>> }
>>
>> I´ve just commented the "return". Now it is cancelling every
>> SelectionKey which is expired.
>>
>> Well, I´m not sure if I did something wrong. I´m afraid to get another
>> problem after I´ve commented that return. My server is working fine
>> and stable, but I´m not 100% sure if what I did is correct.
>>
>> Thanks for any help,
> Good catch! I agree the code seems to be buggy.
>
> More to come...
>
> -- Jeanfrancois
>
>
>
>>
>> Luiz Soares
>>
>>
>>
>>
>> Flickr agora em português. Você clica, todo mundo vê. Saiba mais
>> .
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
For additional commands, e-mail: users-help_at_grizzly.dev.java.net



       Flickr agora em português. Você clica, todo mundo vê. Saiba mais.