adblockplus/adblockplusandroid — pull request #2 by yath (2013-10-10 17:53:50+00:00)
Title: Fix closing socket in brazil's HttpRequest

When calling close() on an HttpRequest instance brazil checks whether
keep-alive is supported. If so, it puts the open connection into a
pool for later re-use.

If there is still data to be received from the socket, a
BackgroundCloser thread is created that a) attempts to read
the remaining data from the socket and b) spawns a Killer
that signals an interrupt to the BackgroundCloser after ten
seconds.

This interrupt, however, does not cause the InputStream.read()
to throw an exception which would in turn get the socket from
the pool closed but rather only kills the thread with the socket
still being open.

This leads to the problem described here in
:
When an HTTP stream gets opened and the client application
terminates, the socket is still being held open and data gets
received until the connection is closed for some other reason.

This patch makes Killer call an abort() method of BackgroundCloser
which in turn closes the socket and kills the BackgroundCloser thread.