changeset 1152:1e020b5801bb

On second thought, do exit on netx failure. JVM respawning code is far more robust than the initialization timeout code, which may put the browser in an unknown state. Remove classpath when initialiazing the jvm -- it is not needed.
author Deepak Bhole <dbhole@redhat.com>
date Thu, 23 Oct 2008 18:07:45 -0400
parents 93f0928ec0ed
children a8f8cb9d58df
files ChangeLog IcedTeaPlugin.cc plugin/icedtea/sun/applet/PluginAppletViewer.java
diffstat 3 files changed, 45 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Oct 23 12:27:23 2008 -0400
+++ b/ChangeLog	Thu Oct 23 18:07:45 2008 -0400
@@ -1,8 +1,8 @@
 2008-10-23  Deepak Bhole  <dbhole@redhat.com>
 
-	* IcedTeaPlugin.cc: Supply classpath to rt.jar when starting java.
-	* plugin/icedtea/sun/applet/PluginAppletViewer.java: Tell Netx to exit VM
-	on error.
+	* IcedTeaPlugin.cc: Implement proper timeout action.
+	* plugin/icedtea/sun/applet/PluginAppletViewer.java: Supply new
+	exitOnFailure argument to Netx.
 	* rt/net/sourceforge/jnlp/Launcher.java: Implement an option for not
 	exiting VM on error.
 	* rt/net/sourceforge/jnlp/NetxPanel.java: Same.
--- a/IcedTeaPlugin.cc	Thu Oct 23 12:27:23 2008 -0400
+++ b/IcedTeaPlugin.cc	Thu Oct 23 18:07:45 2008 -0400
@@ -194,6 +194,12 @@
 	return tv.tv_usec;
 }
 
+inline long get_time_in_s()
+{
+	time_t t;
+	return time(&t);
+}
+
 // __func__ is a variable, not a string literal, so it cannot be
 // concatenated by the preprocessor.
 #define PLUGIN_TRACE_JNIENV() Trace _trace ("JNIEnv::", __func__)
@@ -315,7 +321,6 @@
 // Fully-qualified appletviewer executable.
 gchar* data_directory = NULL;
 static char* appletviewer_executable = NULL;
-static char* appletviewer_classpath = NULL;
 static char* libjvm_so = NULL;
 
 class IcedTeaPluginFactory;
@@ -2391,14 +2396,14 @@
 
            PLUGIN_DEBUG_1ARG ("IcedTeaPluginInstance::SetWindow: Instance %p waiting for initialization...\n", this);
 
-           suseconds_t startTime = get_time_in_ms();
+           long startTime = get_time_in_s();
            PRBool timedOut = PR_FALSE;
 
            while (initialized == PR_FALSE && this->fatalErrorOccurred == PR_FALSE) 
            {
                PROCESS_PENDING_EVENTS;
 
-               if ((get_time_in_ms() - startTime) > TIMEOUT*1000)
+               if ((get_time_in_s() - startTime) > TIMEOUT)
                {
                    timedOut = PR_TRUE;
                    break;
@@ -2407,7 +2412,11 @@
 
             // we timed out
             if (timedOut == PR_TRUE)
-              return NS_ERROR_FAILURE;
+			{
+                PLUGIN_DEBUG_1ARG ("Initialization for instance %d has timed out. Marking it void\n", instance_identifier);
+				this->fatalErrorOccurred = PR_TRUE;
+                return NS_ERROR_FAILURE;
+			}
 
             // did we bail because there is no jvm?
             if (this->fatalErrorOccurred == PR_TRUE)
@@ -2549,13 +2558,29 @@
   if (initialized == PR_FALSE) 
     {
 
-      PLUGIN_DEBUG_1ARG ("IcedTeaPluginInstance::SetWindow: Instance %p waiting for initialization...\n", this);
-
-      while (initialized == PR_FALSE) {
-        PROCESS_PENDING_EVENTS;
-//      printf("waiting for java object\n");
+      PLUGIN_DEBUG_1ARG ("IcedTeaPluginInstance::GetJavaObject: Instance %p waiting for initialization...\n", this);
+
+      long startTime = get_time_in_s();
+      PRBool timedOut = PR_FALSE;
+      while (initialized == PR_FALSE && this->fatalErrorOccurred == PR_FALSE) 
+      {
+          PROCESS_PENDING_EVENTS;
+
+          if ((get_time_in_s() - startTime) > TIMEOUT)
+          {
+              timedOut = PR_TRUE;
+              break;
+           }
       }
 
+      // we timed out
+      if (timedOut == PR_TRUE)
+	  {
+          PLUGIN_DEBUG_1ARG ("IcedTeaPluginInstance::GetJavaObject: Initialization for instance %d has timed out. Marking it void\n", instance_identifier);
+          this->fatalErrorOccurred = PR_TRUE;
+          return NS_ERROR_FAILURE;
+	  }
+
       PLUGIN_DEBUG_1ARG ("Instance %p initialization complete...\n", this);
     }
  
@@ -2590,12 +2615,12 @@
   nsresult result = NS_OK;
 
   // wait for result
-  suseconds_t startTime = get_time_in_ms();
+  long startTime = get_time_in_s();
   while (object_identifier_return == 0) {
 	  current->ProcessNextEvent(PR_TRUE, &processed);
 
 	  // If we have been waiting for more than 20 seconds, something is wrong
-	  if ((get_time_in_ms() - startTime) > TIMEOUT*1000)
+	  if ((get_time_in_ms() - startTime) > TIMEOUT)
 		  break;
   }
 
@@ -3574,18 +3599,16 @@
   
   if (getenv("ICEDTEAPLUGIN_DEBUG"))
   {
-	  numArgs = 6;
-      char const* javaArgs[6] = { "-cp", appletviewer_classpath, "-Xdebug", "-Xnoagent", "-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n", "sun.applet.PluginMain" };
+	  numArgs = 4;
+      char const* javaArgs[4] = { "-Xdebug", "-Xnoagent", "-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n", "sun.applet.PluginMain" };
 	  args = javaArgs;
   } else
   {
-	  numArgs = 3;
-	  char const* javaArgs[3] = { "-cp", appletviewer_classpath, "sun.applet.PluginMain" };
+	  numArgs = 1;
+	  char const* javaArgs[1] = { "sun.applet.PluginMain" };
 	  args = javaArgs;
   }
 
-  printf("Executing: %s %s\n", appletviewer_executable, args);
-
   // start processing thread
   nsCOMPtr<nsIRunnable> processMessageEvent =
 							new IcedTeaRunnableMethod<IcedTeaPluginFactory>
@@ -5561,7 +5584,7 @@
       return NS_ERROR_OUT_OF_MEMORY;
     }
   nsCString executable (dirname (filename));
-  nsCString classpath(dirname (filename));
+
   free (filename);
   filename = NULL;
 
@@ -5575,15 +5598,6 @@
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
-  classpath += nsCString ("/rt.jar");
-  appletviewer_classpath = strdup (classpath.get ());
-  if (!appletviewer_classpath)
-    {
-      PLUGIN_ERROR ("Failed to create java classpath string.");
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-
-
   // Make sure the plugin data directory exists, creating it if
   // necessary.
   data_directory = g_strconcat (getenv ("HOME"), "/.icedteaplugin", NULL);
--- a/plugin/icedtea/sun/applet/PluginAppletViewer.java	Thu Oct 23 12:27:23 2008 -0400
+++ b/plugin/icedtea/sun/applet/PluginAppletViewer.java	Thu Oct 23 18:07:45 2008 -0400
@@ -175,7 +175,7 @@
          AccessController.doPrivileged(new PrivilegedAction() {
              public Object run() {
             	 	try {
-            	 		panel = new NetxPanel(doc, atts, false);
+            	 		panel = new NetxPanel(doc, atts, true);
             	 		AppletViewerPanel.debug("Using NetX panel");
             	 	} catch (Exception ex) {
             	 		AppletViewerPanel.debug("Unable to start NetX applet - defaulting to Sun applet", ex);