Author: toad
Date: 2008-04-21 15:58:55 +0000 (Mon, 21 Apr 2008)
New Revision: 19487

Modified:
   trunk/freenet/src/freenet/node/IPDetectorPluginManager.java
Log:
Call notifyPortChange() off-thread.
This should eliminate the long delay when enabling opennet, which is a 
usability issue on new installations.

Modified: trunk/freenet/src/freenet/node/IPDetectorPluginManager.java
===================================================================
--- trunk/freenet/src/freenet/node/IPDetectorPluginManager.java 2008-04-21 
15:38:19 UTC (rev 19486)
+++ trunk/freenet/src/freenet/node/IPDetectorPluginManager.java 2008-04-21 
15:58:55 UTC (rev 19487)
@@ -851,13 +851,25 @@
                }
        }

-       void notifyPortChange(Set newPorts) {
+       void notifyPortChange(final Set newPorts) {
                FredPluginPortForward[] plugins;
                synchronized(this) {
                        plugins = portForwardPlugins;
                }
-               for(int i=0;i<plugins.length;i++)
-                       plugins[i].onChangePublicPorts(newPorts, this);
+               for(int i=0;i<plugins.length;i++) {
+                       final FredPluginPortForward plugin = plugins[i];
+                       node.executor.execute(new Runnable() {
+
+                               public void run() {
+                                       try {
+                                               
plugin.onChangePublicPorts(newPorts, IPDetectorPluginManager.this);
+                                       } catch (Throwable t) {
+                                               Logger.error(this, "Changing 
public ports list on "+plugin+" threw: "+t, t);
+                                       }
+                               }
+                               
+                       }, "Notify "+plugins[i]+" of ports list change");
+               }
        }

        public void portForwardStatus(Map statuses) {


Reply via email to