Author: FloppusMaximus
Date: 2008-12-12 23:00:55 +0000 (Fri, 12 Dec 2008)
New Revision: 24288

Modified:
   trunk/freenet/src/freenet/io/NetworkInterface.java
Log:
Fixed a bug preventing NetworkInterface.accept() from timing out correctly.

Also have accept() throw an exception if no acceptors are running
(e.g. the interface has been close()d.)

(This is needed for plugins that use NetworkInterface to listen for
connections; with previous version, accept() would never time out,
preventing the plugin from being unloaded.)


Modified: trunk/freenet/src/freenet/io/NetworkInterface.java
===================================================================
--- trunk/freenet/src/freenet/io/NetworkInterface.java  2008-12-12 22:51:15 UTC 
(rev 24287)
+++ trunk/freenet/src/freenet/io/NetworkInterface.java  2008-12-12 23:00:55 UTC 
(rev 24288)
@@ -174,6 +174,7 @@
                for (Acceptor acceptor : acceptors) {
                        acceptor.setSoTimeout(timeout);
                }
+               this.timeout = timeout;
        }
 
        /**
@@ -190,6 +191,9 @@
        public Socket accept() throws SocketTimeoutException {
                synchronized (syncObject) {
                        while (acceptedSockets.size() == 0) {
+                               if (acceptors.size() == 0) {
+                                       throw new SocketTimeoutException();
+                               }
                                try {
                                        syncObject.wait(timeout);
                                } catch (InterruptedException ie1) {

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to