tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <>
Subject Re: APR, WebSocket and Servlet 3.1 NIO refactoring
Date Tue, 15 Jan 2013 19:26:23 GMT
Remy Maucherat <> wrote:

>On Tue, 2013-01-15 at 13:29 +0000, Mark Thomas wrote:
>> Hi,
>> I think I am going to need to refactor the APR Poller code. Before I
>> to far down that road I wanted to get a sanity check from those that
>> understand the APR/native connector better than I do.
>> The main problem:
>> - I need to be able to update the flags for a socket current in the
>> poller. For example, adding FLAGS_WRITE to a socket that currently
>> Side issues:
>> - APR connections don't track number of HTTP keep-alives left (it
>> reset every time the socket goes back to the Poller)
>> - Currently we have two completely separate sets of Pollers. Once for
>> Comet and one for non-Comet.
>> The reasoning for the refactoring:
>> 1. Sockets should only be added to a pollset once.
>> 2. Because of 1) to update the flags the socket needs to be removed
>> the pollset and re-added with the new flags.
>> 3. Currently, we have no record of which Poller a socket is
>> with. This makes 2) more expensive as we have to iterate through the
>> Pollers to find the socket. Tracking the current poller used by a
>> would make 2) a cheaper operation.
>> 4. Implementing 3) requires maintaining a mapping from socket to
>> SocketWrapper (like KeyAttachment does in NIO)
>> 5. A simple Map of Socket->SocketWrapper should give us what we need.
>I had to solve each of these issues in the web container of JBoss.
>Although this is not going to be quite 100% compatible with Tomcat, it
>is very similar.
>I recommend looking at the branch that is in AS 7 trunk:

Thanks. The more I look into this the more strangeness I find. I'll keep
the above in mind if I need some pointers.

>> In addition to enabling me to continue with the Servlet 3.1 NIO work,
>> the other advantages to the proposed refactoring are:
>> - Will be able to eliminate the CometPollers since the SocketWrapper
>> knows if a request is Comet or not.
>> - Proper tracking of HTTP keep-alive requests left per connection.
>> If anyone can see a good reason not to start down this path, please
>> speak up.
>With APR, I would keep a separate poller for events (called comet in
>Tomcat) and keepalive, the code is rather different.

At the moment they are almost identical. I'll see how things develop.



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

View raw message