Julien Vermillard wrote:
Hi,
Following an IRC convo, between alex, tazle and me :
We had a few complaint recently about remaining unclosed socket and
thread after multiple connection using the NioSocketConnector or simply
the AsyncHttpClient not releasing correctly file descriptor on linux.

Indeed - on my machine two NioSocketProcessors and one NioSocketConnector each each seem to leak three fds per AHC connect() invocation, plus two fds of some unix socket, the cause of which I don't know.

The problem for AsyncHttpClient is was because each connection create a
NioSocketConnector and forget to .dispose() it.

My idea was to call dispose() in the sessionClosed() handler of HttpIoHandler, but this proved to cause a deadlock - the Worker of one of the NioSocketProcessors called sessionClosed(), but as a result of the dispose() call was expected to handle the disposition of the NioSocketProcessor in blocking fashion as well, thus blocking on itself.

When you connect and close a session a thread will remain in the
threadpool for 1 minute (it's the default behaviour), you can still
overide it specifying another Executorfilter behaviour.

The file descriptors reserved didn't seem to go anywhere after a minute.

BTW AHC is using 1 SocketConnector per AHC instance, I think it should
be changed to share it.

I think the AHC take some sort of context object, containing the NioSocketConnector with appropriate filter chain.

Reply via email to