tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mladen Turk <>
Subject Re: APR/native and per socket timeouts.
Date Mon, 21 May 2012 14:37:51 GMT
On 05/21/2012 02:55 PM, Mark Thomas 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.

The easier solution would be to use the math inside native
by providing a desired perSocketTimeout and internally substracting from
pollset's ttl. In that case pollset's ttl can be almost anything (well as long
it's not zero which means disabled)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message