You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2014/03/23 23:16:31 UTC

Tracking request state through NIO

All,

I've been poking around the NIOEndpoint code but I can't seem to find
what I'm looking for: a list of states through which a request
progresses while it is going from being accepted through dispatch, and
finally back into the poller (for keep-alives).

I have to imagine that, as a request goes comes out of the poller due to
an I/O event, the thread picking it up has to know where to resume...
such as fetching more SSL handshake data, etc. Where is that state kept,
or do I have it all wrong?

Is there a formal list of states?

Thanks,
-chris


Re: Tracking request state through NIO

Posted by Mark Thomas <ma...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 23/03/2014 22:16, Christopher Schultz wrote:
> All,
> 
> I've been poking around the NIOEndpoint code but I can't seem to
> find what I'm looking for: a list of states through which a
> request progresses while it is going from being accepted through
> dispatch, and finally back into the poller (for keep-alives).
> 
> I have to imagine that, as a request goes comes out of the poller
> due to an I/O event, the thread picking it up has to know where to
> resume... such as fetching more SSL handshake data, etc. Where is
> that state kept, or do I have it all wrong?
> 
> Is there a formal list of states?

And when you looked at this with a debugger you saw... ?

The Poller always calls
NioEndpoint.processSocket(NioChannel,SocketStatus,boolean)

The NioChannel then gets wrapped with a SocketProcessor.

SocketProcessor.doRun() handles any SSL handshake and passes the
socket to the Handler (implementation is the the concrete Protocol
implementation) with most inherited from AbstractProtocol.

In is in Handler.process() that most of the magic happens. If any
state needed to be retained it will have been retained in a Processor
instance added to connections ( Map<Socket,Processor>) which is then
retrieved by looking up the processor for the current socket. A new
HTTP request won't have one. An in progress WebSocket connection will etc.

HTH,

Mark


> 
> Thanks, -chris
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTL1/2AAoJEBDAHFovYFnnvLAP/iEoibERLvlLUKVDSkxe/rcg
XGycnfMVE7cgqPhX7ZNpqLSU0pdGA8UT0arayf7qXbRN8dxqKWBhI8EpP7yZXWXB
AasmAi4hfkWmUNzQwb4Fos/qydWdMaEiGQWXWpT0G5vpYH/c9yaaVD6klebBr8AO
0KvL6Y4C6lDdx6aVuhNB2SUbSJ6WAi6g+1odqWwh2BNtc4da024JzfjvyauSHMpU
DN/Zghq6WDfoidaWlbZlDjhD1QM+E7tiZG4HoAmSR2D5PJQQKD8YXeX0WvH0Oi1e
Wr8He1R1UQ0yqqcITsWzFxEMBWWWogK8DesoIpoQqt9rvCiKUxn9qbSBefq3kzia
0reYkusXPQi60tD02djtBz2SBJmqX6Co5symlci+BfwDWFOJU5W8SezB/V4Dsonj
00V3TSCYtClQmTlcwnwkBUy9pNooxxw98ztzC3IiV3An2ne0htinrWZ7r2fiNtaM
7ZkCJorrVHCGY6G9Uthq1KXgSF5f5Hbk8YmkaltIbDOjGxBbYGCYm1x2PhOSb+H8
SCdiqWoHvev6BJgwIJ49aa5jznJcVp42Kzj44LvAcoS3PIqR35EM8pe270A6ivxZ
P07mYpcmgp3S3bqEptBipjI0mBjFZpkfOd9Aemj97oT1j3f5C1Nzmo+dpORU2hPW
iM3Uz5yxMNX+mQu11NdN
=K6tS
-----END PGP SIGNATURE-----

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