Mercurial > hg > release > icedtea6-1.8
changeset 2052:c691bc07c5e0
Fix race conditions in plugin initialization code that were causing hangs
when loading multiple applets in parallel.
author | Deepak Bhole <dbhole@redhat.com> |
---|---|
date | Wed, 14 Jul 2010 17:42:26 -0400 |
parents | 595ea39174ab |
children | cc8ca057c727 |
files | ChangeLog plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java |
diffstat | 3 files changed, 40 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Jul 14 00:06:12 2010 +0200 +++ b/ChangeLog Wed Jul 14 17:42:26 2010 -0400 @@ -1,3 +1,19 @@ +2010-07-14 Deepak Bhole <dbhole@redhat.com> + + * plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java: Add a new + processedIds list to track which instances have been instantiated. + (okToProcess): Register width as priority only after handle is acquired. + Process resize messages only after tag and handle are processed. + (notifyWorkerIsFree): Add instance id to processedIds list if the worked + being free'd is an init worker. + (getFreeWorker): Create new normal worked only if worker count is less + than MAX_WORKERS - PRIORITY_WORKERS. + (dumpWorkerStatus): New method. Useful when debugging -- prints status of + all workers. + * plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java + (toString): New method. Returns the string representation of the worker + instance at call time. + 2010-07-13 Matthias Klose <doko@ubuntu.com> * acinclude.m4 (IT_CHECK_PLUGIN_DEPENDENCIES): Don't require libxul
--- a/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java Wed Jul 14 00:06:12 2010 +0200 +++ b/plugin/icedteanp/java/sun/applet/PluginMessageConsumer.java Wed Jul 14 17:42:26 2010 -0400 @@ -61,6 +61,7 @@ PluginStreamHandler streamHandler = null; AppletSecurity as; ConsumerThread consumerThread = new ConsumerThread(); + private static ArrayList<Integer> processedIds = new ArrayList<Integer>(); /** * Registers a reference to wait for. Responses to registered priority @@ -162,7 +163,6 @@ } registerPriorityWait("instance " + instanceNum + " handle"); - registerPriorityWait("instance " + instanceNum + " width"); } else if (msgParts[2].equals("handle")) { Integer instanceNum = new Integer(msgParts[1]); @@ -171,6 +171,16 @@ // Handle messages should NEVER go before tag messages if (!isInInit(instanceNum)) return false; + + registerPriorityWait("instance " + instanceNum + " width"); + } else if (msgParts[2].equals("width")) { + + // width messages cannot proceed until handle and tag have been resolved + Integer instanceNum = new Integer(msgParts[1]); + + if (!processedIds.contains(instanceNum)) { + return false; + } } return true; @@ -181,8 +191,10 @@ Iterator<Integer> i = initWorkers.keySet().iterator(); while (i.hasNext()) { Integer key = i.next(); - if (initWorkers.get(key).equals(worker)) + if (initWorkers.get(key).equals(worker)) { + processedIds.add(key); initWorkers.remove(key); + } } } @@ -270,7 +282,7 @@ if (workers.size() <= MAX_WORKERS) { PluginMessageHandlerWorker worker = null; - if (workers.size() <= (MAX_WORKERS - PRIORITY_WORKERS)) { + if (workers.size() < (MAX_WORKERS - PRIORITY_WORKERS)) { PluginDebug.debug("Cannot find free worker, creating worker " + workers.size()); worker = new PluginMessageHandlerWorker(this, streamHandler, workers.size(), as, false); } else if (prioritized) { @@ -291,4 +303,9 @@ return null; } + private void dumpWorkerStatus() { + for (PluginMessageHandlerWorker worker: workers) { + PluginDebug.debug(worker.toString()); + } + } }
--- a/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java Wed Jul 14 00:06:12 2010 +0200 +++ b/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java Wed Jul 14 17:42:26 2010 -0400 @@ -140,4 +140,8 @@ return free && (prioritized == isPriorityWorker); } } + + public String toString() { + return "Worker #" + this.id + "/IsPriority=" + this.isPriorityWorker + "/IsFree=" + this.free + "/Message=" + message; + } }