On Mon, May 21, 2012 at 9:29 AM, Mark Thomas <ma...@apache.org> wrote:
> 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. How is it used in poll ? The poll can be arbitrary - there is no need to guarantee that sockets timeout at the exact moment, it can happen later. If poll time is 1/2 hour - than if no event happens you'll check every 1/2 hour which sockets are expired. The benefit of doing it in java is that you have more control - and may use more advanced structures ( C is just a loop over the list of sockets, wouldn't scale very well to 100K+ sockets - which are probably normal case for websocket ). Costin > 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 > >