You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Chris Reynolds <sh...@gmail.com> on 2011/06/23 18:45:04 UTC

Detect when a TSVConn connection closes

Hi,

I have written a plugin that intercepts HTTP requests by using
TSHttpTxnIntercept and then reads the request and scans it. If it is
allowed then I open a connection to the server by using TSNetConnect
and send the request on.

I have two problems:
1. By using TSNetConnect I bypass Traffic Server's connection pooling
so I have to implement my own by not closing the server connection at
the end of each transaction in case the next transaction needs to
reuse it. It would be better if I could somehow get the NetConnect to
use the connection pooling.
2. I cannot detect when the TSVConn server connection closes. This has
the effect of quite a few sockets being left in a CLOSED_WAIT state
for a while because the server closes the connection but I do not
detect this and only close the TSVConn connection to the server when
the session closes down.

Has anyone got any ideas? Do you think I need to change the Traffic
Server source code to either provide some event that is called when a
TSVConn closes, or change the code so there is a function I can call
that will return the state of a TSVConn - e.g. like TSVConnClosedGet
(which can only be used for transformation TSVConns) - and then
schedule an event to check for this periodically?

Thank-you,

Chris.

Re: Detect when a TSVConn connection closes

Posted by Leif Hedstrom <zw...@apache.org>.
On 06/23/2011 10:45 AM, Chris Reynolds wrote:
> Hi,
>
> I have written a plugin that intercepts HTTP requests by using
> TSHttpTxnIntercept and then reads the request and scans it. If it is
> allowed then I open a connection to the server by using TSNetConnect
> and send the request on.

Hmmm, what is the purpose of the the intercept? Are you using 
TSNetConnect() to connect to a non-HTTP protocol port?  If not, why not 
use TSHttpConnect() ?  Also, if the purpose of this plugin is to simply 
"allow" or "deny" requests to origin, you can do that much simpler than 
as an intercept plugin. The main reason to use intercept would be if you 
are crossing different protocol boundaries, or if you are implementing 
the "origin" side as a plugin.

-- leif