Author: toad
Date: 2007-09-08 15:22:50 +0000 (Sat, 08 Sep 2007)
New Revision: 15040

Modified:
   trunk/freenet/src/freenet/pluginmanager/PluginHandler.java
   trunk/freenet/src/freenet/pluginmanager/PluginManager.java
Log:
removePlugin(PluginInfoWrapper) NOT (Thread) !!!!
- avoid iterating pluginwrappers (originally a hashmap named plugininfo) to 
find it, we already have it
- looks to me like threadless plugins were seriously broken by the thread-based 
lookup; removing threadless plugins which had a toadlet would for example 
probably do bad things

Modified: trunk/freenet/src/freenet/pluginmanager/PluginHandler.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/PluginHandler.java  2007-09-08 
15:19:21 UTC (rev 15039)
+++ trunk/freenet/src/freenet/pluginmanager/PluginHandler.java  2007-09-08 
15:22:50 UTC (rev 15040)
@@ -82,7 +82,7 @@
                                        t.printStackTrace();
                                }
                                if(!(plugin instanceof FredPluginThreadless))
-                                       pm.removePlugin(this);
+                                       pm.removePlugin(pi);
                        } else {
                                // If not FredPlugin, then the whole thing is 
aborted,
                                // and then this method will return, killing 
the thread

Modified: trunk/freenet/src/freenet/pluginmanager/PluginManager.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/PluginManager.java  2007-09-08 
15:19:21 UTC (rev 15039)
+++ trunk/freenet/src/freenet/pluginmanager/PluginManager.java  2007-09-08 
15:22:50 UTC (rev 15040)
@@ -172,24 +172,17 @@
         * have registered. This is eventually called whenever any plugin is 
removed.
         * @param t
         */
-       public void removePlugin(Thread t) {
+       public void removePlugin(PluginInfoWrapper pi) {
                PluginInfoWrapper removed = null;
                synchronized (pluginWrappers) {
-                       for(int i=0;i<pluginWrappers.size();i++) {
-                               PluginInfoWrapper pi = (PluginInfoWrapper) 
pluginWrappers.get(i);
-                               if (pi.sameThread(t)) {
-                                       removed = pi;
-                                       synchronized (toadletList) {
-                                               try {
-                                                       
toadletList.remove(pi.getPluginClassName());
-                                                       Logger.normal(this, 
"Removed HTTP handler for /plugins/"+
-                                                                       
pi.getPluginClassName()+ '/', new Exception("debug"));
-                                               } catch (Throwable ex) {
-                                                       Logger.error(this, 
"removing Plugin", ex);
-                                               }
-                                       }
-                                       pluginWrappers.remove(i);
-                                       i--;
+                       pluginWrappers.remove(pi);
+                       synchronized (toadletList) {
+                               try {
+                                       
toadletList.remove(pi.getPluginClassName());
+                                       Logger.normal(this, "Removed HTTP 
handler for /plugins/"+
+                                                       
pi.getPluginClassName()+ '/', new Exception("debug"));
+                               } catch (Throwable ex) {
+                                       Logger.error(this, "removing Plugin", 
ex);
                                }
                        }
                }
@@ -301,7 +294,7 @@
                }
                if (found)
                        if (pi.isThreadlessPlugin())
-                               removePlugin(pi.getThread());
+                               removePlugin(pi);
                        else
                                pi.stopPlugin();
        }


Reply via email to