hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Closing the persisted server connections on IOReactor pause
Date Sun, 18 Apr 2010 10:47:00 GMT
On Sun, 2010-04-18 at 08:00 +0530, Ruwan Linton wrote:
> Hi Oleg,
> 
> 
> > Hi Ruwan
> >
> > You have got to be very careful here. HTTP connection objects are not
> > thread safe! One can easily run into a race condition when interacting
> > with connection objects from any other but an I/O dispatch thread.
> >
> 
> I have already encountered the above issue, and had a look at the
> NhttpConnection class JavaDoc and realized this.
> 
> 
> >
> > So, Here is the recommended way of going about this problem. You should
> > signal the intention to terminate the connection by setting a special
> > attribute in the session context or changing the state of the shared
> > connection state object and let the connection shut down itself, when it
> > is done processing the actual message.
> 
> 
> Thanks a lot for this valuable input, I was thinking how I can proceed with
> my limited knowledge on httpcore. Really appreciate this help.
> 
> 
> > If the persistent connection is
> > idle, you may need to active it by using the IOControl interface.
> >
> 
> May be I didn't get this part, could you please tell me how to check whether
> the connection is idle or not?
> 

Hi Ruwan

There is simply no reliable way to test that. By the time you are done
checking, the connection may finish message processing and become idle.
So, what you should do it to update the connection state (for instance,
in this particular case, by setting a termination request flag),
activate the connection by requesting output processing with
IOControl#requestOutput and let the connection react to the changed
state.

Hope this helps

Oleg




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


Mime
View raw message