tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: svn commit: r1296172 - in /tomcat/trunk/java/org/apache/coyote: AbstractProtocol.java ajp/AbstractAjpProtocol.java http11/Http11AprProtocol.java http11/Http11NioProtocol.java http11/Http11Protocol.java
Date Fri, 02 Mar 2012 13:52:52 GMT
On 02/03/2012 13:17, Johno Crawford wrote:
> Hi Mark,
> 
> Quick question regarding web socket socket states, using the BIO
> connector I have observed the socket state never transitions to
> UPGRADED.. Is this the expected behaviour?

Short answer: yes.

Longer answer: In this case state is the state at a particular point in
time rather than state as one might think of in terms of a state
machine. Because BIO is blocking rather than exiting the loop in
StreamInbound#onData() with a state of UPGRADED it blocks waiting for
more data to turn up. It it did exit, all that would happen is that 10s
of lines of code latter the thread (more likely a different thread)
would end up back in StreamInbound#onData() blocking on a read. The
current way of looping is just more efficient.

HTH,

Mark


> Cheers,
> 
> Johno
> 
> On 2/03/2012 1:41 PM, markt@apache.org wrote:
>> Author: markt
>> Date: Fri Mar  2 12:41:54 2012
>> New Revision: 1296172
>>
>> URL: http://svn.apache.org/viewvc?rev=1296172&view=rev
>> Log:
>> No need for an upgrade specific poll method. Delete some more code :)
>>
>> Modified:
>>      tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
>>      tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
>>      tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
>>      tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
>>      tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java
>>
>> Modified: tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
>> URL:
>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java?rev=1296172&r1=1296171&r2=1296172&view=diff
>>
>> ==============================================================================
>>
>> --- tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java (original)
>> +++ tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java Fri Mar 
>> 2 12:41:54 2012
>> @@ -591,7 +591,7 @@ public abstract class AbstractProtocol i
>>                       release(socket, processor, false, false);
>>                   } else if (state == SocketState.UPGRADED) {
>>                       // Need to keep the connection associated with
>> the processor
>> -                    upgradePoll(socket, processor);
>> +                    longPoll(socket, processor);
>>                   } else {
>>                       // Connection closed. OK to recycle the processor.
>>                       if (!(processor instanceof UpgradeProcessor)) {
>> @@ -630,8 +630,6 @@ public abstract class AbstractProtocol i
>>                   Processor<S>  processor);
>>           protected abstract void longPoll(SocketWrapper<S>  socket,
>>                   Processor<S>  processor);
>> -        protected abstract void upgradePoll(SocketWrapper<S>  socket,
>> -                Processor<S>  processor);
>>           protected abstract void release(SocketWrapper<S>  socket,
>>                   Processor<S>  processor, boolean socketClosing,
>>                   boolean addToPoller);
>>
>> Modified:
>> tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
>> URL:
>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java?rev=1296172&r1=1296171&r2=1296172&view=diff
>>
>> ==============================================================================
>>
>> --- tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
>> (original)
>> +++ tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
>> Fri Mar  2 12:41:54 2012
>> @@ -91,12 +91,6 @@ public abstract class AbstractAjpProtoco
>>           }
>>
>>           @Override
>> -        protected void upgradePoll(SocketWrapper<S>  socket,
>> -                Processor<S>  processor) {
>> -            // TODO Should never happen. ISE?
>> -        }
>> -
>> -        @Override
>>           protected P createUpgradeProcessor(SocketWrapper<S>  socket,
>>                   UpgradeInbound inbound) {
>>               // TODO should fail - throw IOE
>>
>> Modified:
>> tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
>> URL:
>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java?rev=1296172&r1=1296171&r2=1296172&view=diff
>>
>> ==============================================================================
>>
>> --- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
>> (original)
>> +++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
>> Fri Mar  2 12:41:54 2012
>> @@ -293,22 +293,20 @@ public class Http11AprProtocol extends A
>>               connections.put(socket.getSocket(), processor);
>>
>>               if (processor.isAsync()) {
>> +                // Async
>>                   socket.setAsync(true);
>>               } else if (processor.isComet()&& 
>> proto.endpoint.isRunning()) {
>> +                // Comet
>>                   ((AprEndpoint) proto.endpoint).getCometPoller().add(
>>                           socket.getSocket().longValue(), false);
>> +            } else {
>> +                // Upgraded
>> +                ((AprEndpoint) proto.endpoint).getPoller().add(
>> +                        socket.getSocket().longValue(), false);
>>               }
>>           }
>>
>>           @Override
>> -        protected void upgradePoll(SocketWrapper<Long>  socket,
>> -                Processor<Long>  processor) {
>> -            connections.put(socket.getSocket(), processor);
>> -            ((AprEndpoint) proto.endpoint).getPoller().add(
>> -                    socket.getSocket().longValue(), false);
>> -        }
>> -
>> -        @Override
>>           protected Http11AprProcessor createProcessor() {
>>               Http11AprProcessor processor = new Http11AprProcessor(
>>                       proto.getMaxHttpHeaderSize(),
>> (AprEndpoint)proto.endpoint,
>>
>> Modified:
>> tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
>> URL:
>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java?rev=1296172&r1=1296171&r2=1296172&view=diff
>>
>> ==============================================================================
>>
>> --- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
>> (original)
>> +++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
>> Fri Mar  2 12:41:54 2012
>> @@ -249,6 +249,7 @@ public class Http11NioProtocol extends A
>>               } else {
>>                   // Either:
>>                   //  - this is comet request
>> +                //  - this is an upgraded connection
>>                   //  - the request line/headers have not been completely
>>                   //    read
>>                   socket.getSocket().getPoller().add(socket.getSocket());
>> @@ -285,12 +286,5 @@ public class Http11NioProtocol extends A
>>               return new UpgradeNioProcessor(socket, inbound,
>>                       ((Http11NioProtocol)
>> getProtocol()).getEndpoint().getSelectorPool());
>>           }
>> -
>> -        @Override
>> -        protected void upgradePoll(SocketWrapper<NioChannel>  socket,
>> -                Processor<NioChannel>  processor) {
>> -            connections.put(socket.getSocket(), processor);
>> -            socket.getSocket().getPoller().add(socket.getSocket());
>> -        }
>>       }
>>   }
>>
>> Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java
>> URL:
>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java?rev=1296172&r1=1296171&r2=1296172&view=diff
>>
>> ==============================================================================
>>
>> --- tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java
>> (original)
>> +++ tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java Fri
>> Mar  2 12:41:54 2012
>> @@ -191,11 +191,5 @@ public class Http11Protocol extends Abst
>>                   throws IOException {
>>               return new UpgradeBioProcessor(socket, inbound);
>>           }
>> -
>> -        @Override
>> -        protected void upgradePoll(SocketWrapper<Socket>  socket,
>> -                Processor<Socket>  processor) {
>> -            connections.put(socket.getSocket(), processor);
>> -        }
>>       }
>>   }
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 


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


Mime
View raw message