do not flush the output stream on Endpoint.close(). This fixes the long shutdown time

pull/24/head
Zlatin Balevsky 2019-10-29 12:38:41 +00:00
parent e5b12701f5
commit fa9c697bfa
2 changed files with 2 additions and 22 deletions

View File

@ -27,17 +27,6 @@ import net.i2p.data.Destination
@Log
abstract class Connection implements Closeable {
/**
* This exists because the reset() method blocks for a long time
* even though the javadocs say it's non-blocking. When that gets
* fixed on the I2P side, this can be removed.
*/
private static final ExecutorService CLOSER = Executors.newCachedThreadPool( {r ->
def rv = new Thread(r,"connection closer")
rv.setDaemon(true)
rv
} as ThreadFactory)
private static final int SEARCHES = 10
private static final long INTERVAL = 1000
@ -98,14 +87,8 @@ abstract class Connection implements Closeable {
log.info("closing $name")
reader.interrupt()
writer.interrupt()
CountDownLatch latch = new CountDownLatch(1)
CLOSER.submit({
endpoint.close()
latch.countDown()
log.info("closed $name")
})
latch.await(1000, TimeUnit.MILLISECONDS)
endpoint.close()
log.info("closed $name")
eventBus.publish(new DisconnectionEvent(destination: endpoint.destination))
}

View File

@ -31,9 +31,6 @@ class Endpoint implements Closeable {
if (inputStream != null) {
try {inputStream.close()} catch (Exception ignore) {}
}
if (outputStream != null) {
try {outputStream.close()} catch (Exception ignore) {}
}
if (toClose != null) {
try {toClose.reset()} catch (Exception ignore) {}
}