tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: APR, WebSocket and Servlet 3.1 NIO refactoring
Date Tue, 15 Jan 2013 19:26:23 GMT
Remy Maucherat <remm@apache.org> 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
>get
>> 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
>has
>> FLAGS_READ
>> 
>> Side issues:
>> - APR connections don't track number of HTTP keep-alives left (it
>gets
>> 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
>from
>> the pollset and re-added with the new flags.
>> 3. Currently, we have no record of which Poller a socket is
>registered
>> 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
>socket
>> 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:
>http://anonsvn.jboss.org/repos/jbossweb/branches/7.2.x/

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.

Cheers,

Mark

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


Mime
View raw message