On 21/05/2012 15:26, Costin Manolache wrote:
> My understanding is that the timeout is implemented in poll.c maintain() -
> by scanning the socket list in C.
> 
> Why not doing the same thing in java - i.e. don't touch native code, have
> all sockets 'long', and close whenever you need from java ?

The timeout is also used in poll so it wouldn't be a completely clean
solution. It would probably work but there might be some odd edge cases.
It think it is probably better - for now - to keep this in native.

Mark


> 
> Costin
> 
> On Mon, May 21, 2012 at 5:55 AM, Mark Thomas <ma...@apache.org> wrote:
> 
>> On 20/05/2012 21:47, Mladen Turk wrote:
>>> On 05/20/2012 08:37 PM, Mark Thomas wrote:
>>>> Therefore, I intend modifying the APR/native code to support per socket
>>>> time outs. I would be grateful if those of you with more C knowledge
>>>> than I (which is most people on this list) could:
>>>> a) tell me now if this is a crazy idea (and why)
>>>> b) keep an extra close eye on any commit of mine that touches the C
>> code.
>>>>
>>>
>>> This should be easy to implement.
>>> Inside native we track socket_ttl for each socket.
>>> Currently when  socket is added it's set to apr_time_now()
>>> and later compared with max_ttl (usually keepAliveTimeout).
>>>
>>> We can add new API that would add socket with timeout relative
>>> to max_ttl. A bit awkward but wouldn't create backward incompatibility.
>>>
>>> Take a look at poll.c add function.
>>> The new addt would have additional timeout parameter and
>>> you would set:
>>> ...
>>> if (p->max_ttl > 0)
>>>         p->socket_ttl[p->nelts] = apr_time_now() + J2T(timeout);
>>> ...
>>>
>>> Now that new timeout param would actually be called as
>>> Poll.add(pollset, socket, events, perSocketPollTimeout -
>> keepAliveTimeout);
>>> given that keepAliveTimeout was used for Poll.setTtl(keepAliveTimeout);
>>>
>>> So effectively socket_ttl would become 'now() - ttlOffset'
>>
>> Thanks for confirming I am heading in the right direction with this. I'm
>> hesitant to follow exactly the path above. While it is a minimal change
>> from the current code, I think it could be difficult for folks new to
>> the code to figure out what is going on.
>>
>> I'd like to see if I can come up with a change that will be more obvious
>> on first reading. I expect it will be a little more invasive than the
>> change you suggested. Depending on my level of confidence, I'll either
>> post a patch or commit the change when I have something concrete.
>>
>> Cheers,
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: dev-h...@tomcat.apache.org
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to