From 21c49ad96762ef3af27dd043a044e37b8ef1c22e Mon Sep 17 00:00:00 2001 From: Gurmeen Bindra Date: Fri, 9 Aug 2013 10:50:29 +0100 Subject: Close selector with socketchannel I left MLC which is an XMPP Client running overnight and noticed "Too many open files" error when trying to stop/start xmpp server. On doing an "lsof | grep java", I noticed a large number of open sockets which was presumably the cause of this error. After this patch, the lsof command shows a constant number of open sockets. Test-information: tested on centos vm by doing "lsof | grep java " wc-l"-open sockets do not increase. Change-Id: I7ddff78a1efb005177427fda21f1d0b92d8ed7cc Reviewer: Kevin Smith diff --git a/src/com/isode/stroke/network/JavaConnection.java b/src/com/isode/stroke/network/JavaConnection.java index efbf54f..2069e33 100644 --- a/src/com/isode/stroke/network/JavaConnection.java +++ b/src/com/isode/stroke/network/JavaConnection.java @@ -132,6 +132,7 @@ public class JavaConnection extends Connection implements EventOwner { if(socketChannel_ != null) { try { socketChannel_.close(); + selector_.close(); } catch (IOException ex) { /* Do we need to return an error if we're already trying to close? */ } -- cgit v0.10.2-6-g49f6