RFC: 2 minor fixes for the plugin

Deepak Bhole dbhole at redhat.com
Tue Apr 7 12:11:15 PDT 2009


Attached are 2 patches for 2 minor issues in the plugin. The first one
(rhbz478561.patch) fixes a problem whereby the plugin hangs if Java side
returns an empty string. Thanks to Omair for tracing the issue!

The second patch bumps the maximum number of workers from 3 to 20. With
the new proxy support patch, this patch is now necessary to support
pages with multiple applets.

Test instructions for patch1: https://bugzilla.redhat.com/show_bug.cgi?id=478561
Test site for patch2 (won't work with HEAD - patch): http://www.w3.org/People/mimasa/test/object/java/Othello

-- ChangeLog --

2009-04-07 Deepak Bhole <dbhole at redhat.com>

    * IcedTeaPlugin.cc: Fix rhbz478561 (freeze with empty string return from
    Java side).
    * plugin/icedtea/sun/applet/PluginMessageConsumer.java: Bump max workers
    from 3 to 20, limiting initial to 3, and growing if/when needed.

---------------

Deepak
-------------- next part --------------
diff -r 953caf041bef IcedTeaPlugin.cc
--- a/IcedTeaPlugin.cc	Tue Apr 07 10:28:20 2009 -0400
+++ b/IcedTeaPlugin.cc	Tue Apr 07 14:54:00 2009 -0400
@@ -588,7 +588,7 @@
   PLUGIN_DEBUG_0ARG ("RECEIVE VALUE 1\n");                                             \
   ResultContainer *resultC;                                              \
   factory->result_map.Get(reference, &resultC);                         \
-  while (resultC->returnValue == "" && \
+  while (resultC->returnValue.IsVoid() == PR_TRUE && \
 	     resultC->errorOccurred == PR_FALSE)            \
     {                                                                      \
       PROCESS_PENDING_EVENTS_REF (reference);                                   \
@@ -607,7 +607,7 @@
   PLUGIN_DEBUG_0ARG("RECEIVE SIZE 1\n");                                 \
   ResultContainer *resultC;                                              \
   factory->result_map.Get(reference, &resultC);                         \
-  while (resultC->returnValue == "" && \
+  while (resultC->returnValue.IsVoid() == PR_TRUE && \
 	     resultC->errorOccurred == PR_FALSE) \
     {                                                           \
       PROCESS_PENDING_EVENTS_REF (reference);                        \
@@ -631,7 +631,7 @@
   PLUGIN_DEBUG_0ARG("RECEIVE STRING 1\n");                                 \
   ResultContainer *resultC;                                              \
   factory->result_map.Get(reference, &resultC);                         \
-  while (resultC->returnValue == "" && \
+  while (resultC->returnValue.IsVoid() == PR_TRUE && \
 	     resultC->errorOccurred == PR_FALSE)  \
     {                                                           \
       PROCESS_PENDING_EVENTS_REF (reference);                        \
@@ -655,7 +655,7 @@
   PLUGIN_DEBUG_0ARG("RECEIVE STRING UCS 1\n");                                 \
   ResultContainer *resultC;                                              \
   factory->result_map.Get(reference, &resultC);                         \
-  while (resultC->returnValueUCS.IsEmpty() && \
+  while (resultC->returnValueUCS.IsVoid() == PR_TRUE && \
 	     resultC->errorOccurred == PR_FALSE) \
     {                                                           \
       PROCESS_PENDING_EVENTS_REF (reference);                        \
@@ -855,6 +855,8 @@
 	returnIdentifier = -1;
 	returnValue.Truncate();
 	returnValueUCS.Truncate();
+	returnValue.SetIsVoid(PR_TRUE);
+	returnValueUCS.SetIsVoid(PR_TRUE);
 	errorMessage.Truncate();
 	errorOccurred = PR_FALSE;
 
@@ -877,6 +879,8 @@
 	returnIdentifier = -1;
 	returnValue.Truncate();
 	returnValueUCS.Truncate();
+	returnValue.SetIsVoid(PR_TRUE);
+	returnValueUCS.SetIsVoid(PR_TRUE);
 	errorMessage.Truncate();
 	errorOccurred = PR_FALSE;
 
@@ -3352,7 +3356,8 @@
           
 		   ResultContainer *resultC;
 		   result_map.Get(reference, &resultC);
-		   resultC->returnValue = rest; 
+		   resultC->returnValue = rest;
+		   resultC->returnValue.SetIsVoid(PR_FALSE);
            PLUGIN_DEBUG_1ARG ("PLUGIN GOT RETURN VALUE: %s\n", resultC->returnValue.get());
         }
       else if (command == "GetStringUTFChars")
@@ -3440,6 +3445,7 @@
 		  ResultContainer *resultC;
 		  result_map.Get(reference, &resultC);
 		  resultC->returnValueUCS = returnValueUCS;
+		  resultC->returnValueUCS.SetIsVoid(PR_FALSE);
 
         }
       // Do nothing for: SetStaticField, SetField, ExceptionClear,
-------------- next part --------------
diff -r 953caf041bef plugin/icedtea/sun/applet/PluginMessageConsumer.java
--- a/plugin/icedtea/sun/applet/PluginMessageConsumer.java	Tue Apr 07 10:28:20 2009 -0400
+++ b/plugin/icedtea/sun/applet/PluginMessageConsumer.java	Tue Apr 07 14:54:00 2009 -0400
@@ -35,7 +35,6 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
-
 package sun.applet;
 
 import java.util.ArrayList;
@@ -45,17 +44,19 @@
 
 class PluginMessageConsumer {
 
-	int MAX_WORKERS = 3;
+	int MAX_WORKERS = 20;
 	LinkedList<String> readQueue = new LinkedList<String>();
 	ArrayList<PluginMessageHandlerWorker> workers = new ArrayList<PluginMessageHandlerWorker>();
 	PluginStreamHandler streamHandler = null;
+	AppletSecurity as;
 
 	public PluginMessageConsumer(PluginStreamHandler streamHandler) {
 		
-		AppletSecurity as = new AppletSecurity();
+		as = new AppletSecurity();
 		this.streamHandler = streamHandler;
 
-		for (int i=0; i < MAX_WORKERS; i++) {
+		// create some workers at the start...
+		for (int i=0; i < 3; i++) {
 			PluginDebug.debug("Creating worker " + i);
 			PluginMessageHandlerWorker worker = new PluginMessageHandlerWorker(streamHandler, i, as);
 			worker.start();
@@ -96,6 +97,19 @@
 					return worker;
 				}
 			}
+			
+			// If we have less than MAX_WORKERS, create a new worker
+			if (workers.size() < MAX_WORKERS) {
+			    PluginDebug.debug("Cannot find free worker, creating worker " + workers.size());
+			    PluginMessageHandlerWorker worker = new PluginMessageHandlerWorker(streamHandler, workers.size(), as);
+			    worker.start();
+			    workers.add(worker);
+			    worker.busy();
+			    return worker;
+			} else {
+			    // else wait
+			}
+
 			Thread.yield();
 		}
 


More information about the distro-pkg-dev mailing list