diff options
author | Thomas Watson | 2016-02-18 14:51:35 +0000 |
---|---|---|
committer | Thomas Watson | 2016-02-18 14:54:04 +0000 |
commit | 05d4b77e904d06e6d2c1bff98231447db2ab7195 (patch) | |
tree | 748d48b0da3f85e478bc708281bf6163c19e13a4 | |
parent | 0d49b920587d8a11fd4db5009a243808ab323945 (diff) | |
download | rt.equinox.framework-05d4b77e904d06e6d2c1bff98231447db2ab7195.tar.gz rt.equinox.framework-05d4b77e904d06e6d2c1bff98231447db2ab7195.tar.xz rt.equinox.framework-05d4b77e904d06e6d2c1bff98231447db2ab7195.zip |
Bug 487842 - Unable to acquire state change lock for the module when
starting a bundle
- set the inStartResolve flag for the entire start operation while
holding the STARTED state change lock. Otherwise there is a very small
window where the check for inStartResolve can happen too early by the
resolve operation resulting in another thread winning to start the
module.
Change-Id: I1e5a7f3216c8425a6dc7987a8d915a11886504db
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java index 846635f96..7970b4f8b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/Module.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2014 IBM Corporation and others. + * Copyright (c) 2012, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -396,6 +396,7 @@ public abstract class Module implements BundleReference, BundleStartLevel, Compa boolean lockedStarted = false; lockStateChange(ModuleEvent.STARTED); try { + inStartResolve.incrementAndGet(); lockedStarted = true; checkValid(); if (StartOptions.TRANSIENT_IF_AUTO_START.isContained(options) && !settings.contains(Settings.AUTO_START)) { @@ -415,21 +416,16 @@ public abstract class Module implements BundleReference, BundleStartLevel, Compa return; if (getState().equals(State.INSTALLED)) { ResolutionReport report; - inStartResolve.incrementAndGet(); + // must unlock to avoid out of order locks when multiple unresolved + // bundles are started at the same time from different threads + unlockStateChange(ModuleEvent.STARTED); + lockedStarted = false; try { - // must unlock to avoid out of order locks when multiple unresolved - // bundles are started at the same time from different threads - unlockStateChange(ModuleEvent.STARTED); - lockedStarted = false; - try { - - report = getRevisions().getContainer().resolve(Arrays.asList(this), true); - } finally { - lockStateChange(ModuleEvent.STARTED); - lockedStarted = true; - } + + report = getRevisions().getContainer().resolve(Arrays.asList(this), true); } finally { - inStartResolve.decrementAndGet(); + lockStateChange(ModuleEvent.STARTED); + lockedStarted = true; } // need to check valid again in case someone uninstalled the bundle checkValid(); @@ -460,6 +456,7 @@ public abstract class Module implements BundleReference, BundleStartLevel, Compa if (lockedStarted) { unlockStateChange(ModuleEvent.STARTED); } + inStartResolve.decrementAndGet(); } if (event != null) { |