From 8b5c0a2db112f2944b9f64591a412910e3a2d934 Mon Sep 17 00:00:00 2001 From: sponge Date: Wed, 24 Nov 2010 14:31:54 +0000 Subject: [PATCH 1/2] Plugin: ticket 104 Fix webapp isRunning to check ALL webapps. The only defecency is that if one is running, that it considers the entire pliugin to be running. I'm not sure if that is a good thing or a bad thing, but the other code checks threads that way. --- .../src/net/i2p/router/web/PluginStarter.java | 31 +++++++++++++++++-- history.txt | 6 ++++ .../src/net/i2p/router/RouterVersion.java | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java b/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java index 6958b350e..c44b34f39 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java @@ -50,6 +50,7 @@ public class PluginStarter implements Runnable { private static Map pluginThreadGroups = new ConcurrentHashMap(); // one thread group per plugin (map key=plugin name) private static Map> pluginJobs = new ConcurrentHashMap>(); private static Map _clCache = new ConcurrentHashMap(); + private static Map> pluginWars = new ConcurrentHashMap>(); public PluginStarter(RouterContext ctx) { _context = ctx; @@ -125,6 +126,8 @@ public class PluginStarter implements Runnable { File webappDir = new File(consoleDir, "webapps"); String fileNames[] = webappDir.list(RouterConsoleRunner.WarFilenameFilter.instance()); if (fileNames != null) { + if(!pluginWars.containsKey(appName)) + pluginWars.put(appName, new ConcurrentHashSet()); for (int i = 0; i < fileNames.length; i++) { try { String warName = fileNames[i].substring(0, fileNames[i].lastIndexOf(".war")); @@ -139,6 +142,7 @@ public class PluginStarter implements Runnable { //log.error("Starting webapp: " + warName); String path = new File(webappDir, fileNames[i]).getCanonicalPath(); WebAppStarter.startWebApp(ctx, server, warName, path); + pluginWars.get(appName).add(warName); } } catch (IOException ioe) { log.error("Error resolving '" + fileNames[i] + "' in '" + webappDir, ioe); @@ -215,6 +219,7 @@ public class PluginStarter implements Runnable { // stop console webapps in console/webapps Server server = WebAppStarter.getConsoleServer(); if (server != null) { + /* File consoleDir = new File(pluginDir, "console"); Properties props = RouterConsoleRunner.webAppProperties(consoleDir.getAbsolutePath()); File webappDir = new File(consoleDir, "webapps"); @@ -228,6 +233,13 @@ public class PluginStarter implements Runnable { WebAppStarter.stopWebApp(server, warName); } } + */ + Iterator wars = pluginWars.get(appName).iterator(); + while (wars.hasNext()) { + String warName = wars.next(); + WebAppStarter.stopWebApp(server, warName); + } + pluginWars.get(appName).clear(); } // remove summary bar link @@ -487,10 +499,25 @@ public class PluginStarter implements Runnable { isJobRunning = true; break; } + boolean isWarRunning = false; + if(pluginWars.containsKey(pluginName)) { + Iterator it = pluginWars.get(pluginName).iterator(); + while(it.hasNext() && !isWarRunning) { + String warName = it.next(); + if(WebAppStarter.isWebAppRunning(warName)) { + isWarRunning = true; + } + } + } if (log.shouldLog(Log.DEBUG)) - log.debug("plugin name = <" + pluginName + ">; threads running? " + isClientThreadRunning(pluginName) + "; webapp runing? " + WebAppStarter.isWebAppRunning(pluginName) + "; jobs running? " + isJobRunning); - return isClientThreadRunning(pluginName) || WebAppStarter.isWebAppRunning(pluginName) || isJobRunning; + log.debug("plugin name = <" + pluginName + ">; threads running? " + isClientThreadRunning(pluginName) + "; webapp runing? " + isWarRunning + "; jobs running? " + isJobRunning); + return isClientThreadRunning(pluginName) || isWarRunning || isJobRunning; + // + //if (log.shouldLog(Log.DEBUG)) + // log.debug("plugin name = <" + pluginName + ">; threads running? " + isClientThreadRunning(pluginName) + "; webapp runing? " + WebAppStarter.isWebAppRunning(pluginName) + "; jobs running? " + isJobRunning); + //return isClientThreadRunning(pluginName) || WebAppStarter.isWebAppRunning(pluginName) || isJobRunning; + // } /** diff --git a/history.txt b/history.txt index 398b6ca0c..8fe1f6c0d 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,9 @@ +2010-11-24 sponge + * Plugin: ticket 104 Fix webapp isRunning to check ALL webapps. + The only defecency is that if one is running, that it considers the + entire pliugin to be running. I'm not sure if that is a good thing + or a bad thing, but the other code checks threads that way. + 2010-11-22 zzz * Addressbook: Fix rename error on Windows (tkt 323 - thanks RN!) * build.xml: Cleanup, fix distclean error in older ants. diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index f6e6df3a5..4e28a2c8d 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 4; + public final static long BUILD = 5; /** for example "-test" */ public final static String EXTRA = ""; From 5f3834d3983a64c5139f183b955cb795a88f3781 Mon Sep 17 00:00:00 2001 From: sponge Date: Wed, 24 Nov 2010 14:55:53 +0000 Subject: [PATCH 2/2] Slackware, fix rc.i2p, bad logic. --- Slackware/i2p-base/rc.i2p_def | 2 +- history.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Slackware/i2p-base/rc.i2p_def b/Slackware/i2p-base/rc.i2p_def index 075e9e847..c231922e5 100644 --- a/Slackware/i2p-base/rc.i2p_def +++ b/Slackware/i2p-base/rc.i2p_def @@ -4,7 +4,7 @@ i2p_start() { # Check if router is up first! /bin/su - -c "( export PATH=\"$PATH:/usr/lib/java/bin:/usr/lib/java/jre/bin\"; directory status )" > /dev/null - if [ ! $? -eq 0 ] ; then { + if [ $? -eq 0 ] ; then { # I2p is already running, so tell the user. echo "I2P is already running..." i2p_status diff --git a/history.txt b/history.txt index 8fe1f6c0d..00b97e989 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,6 @@ +2010-11-24 sponge + * Slackware, fix rc.i2p, bad logic. + 2010-11-24 sponge * Plugin: ticket 104 Fix webapp isRunning to check ALL webapps. The only defecency is that if one is running, that it considers the