Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2008-01-30 19:17:06 +0000
committerThomas Watson2008-01-30 19:17:06 +0000
commit6d38daad6d8f0ff3014ebc35a36283c9ed15e61c (patch)
tree261c2c8cb3e4182fd66d09b11d3e5118f8cd3c61 /bundles/org.eclipse.osgi/resolver
parent9c806f6e37e0dcbc56602861d6f1670215166a12 (diff)
downloadrt.equinox.framework-6d38daad6d8f0ff3014ebc35a36283c9ed15e61c.tar.gz
rt.equinox.framework-6d38daad6d8f0ff3014ebc35a36283c9ed15e61c.tar.xz
rt.equinox.framework-6d38daad6d8f0ff3014ebc35a36283c9ed15e61c.zip
Bug 217094 Resolver should timeout when resolving "uses" clauses takes too long
Diffstat (limited to 'bundles/org.eclipse.osgi/resolver')
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java19
1 files changed, 6 insertions, 13 deletions
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
index fce702fe8..0b9350f45 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
@@ -37,7 +37,8 @@ public class ResolverImpl implements org.eclipse.osgi.service.resolver.Resolver
public static boolean DEBUG_GROUPING = false;
public static boolean DEBUG_CYCLES = false;
private static int MAX_MULTIPLE_SUPPLIERS_MERGE = 10;
- private static long MAX_COMBINATIONS = 1000000;
+ private static int MAX_USES_TIME_BASE = 30000; // 30 seconds
+ private static int MAX_USES_TIME_LIMIT = 90000; // 90 seconds
private static String[][] CURRENT_EES;
@@ -585,7 +586,7 @@ public class ResolverImpl implements org.eclipse.osgi.service.resolver.Resolver
}
ResolverConstraint[][] multipleSuppliers = getMultipleSuppliers(bundles, packageConstraints, bundleConstraints);
ArrayList conflicts = null;
- if (multipleSuppliers.length > 0 && getNumCombinations(multipleSuppliers) < MAX_COMBINATIONS) {
+ if (multipleSuppliers.length > 0) {
int[] bestCombination = new int[multipleSuppliers.length];
conflicts = findBestCombination(bundles, multipleSuppliers, bestCombination, initialConflicts);
for (int i = 0; i < bestCombination.length; i++) {
@@ -601,16 +602,6 @@ public class ResolverImpl implements org.eclipse.osgi.service.resolver.Resolver
return conflicts;
}
- private long getNumCombinations(ResolverConstraint[][] multipleSuppliers) {
- if (multipleSuppliers == null || multipleSuppliers.length == 0)
- return 0;
- long numCombinations = multipleSuppliers[0][0].getNumPossibleSuppliers();
- for (int i = 1; i < multipleSuppliers.length; i++)
- if (multipleSuppliers[i].length > 0)
- numCombinations *= multipleSuppliers[i][0].getNumPossibleSuppliers();
- return numCombinations;
- }
-
private int[] getCombination(ResolverConstraint[][] multipleSuppliers, int[] combination) {
for (int i = 0; i < combination.length; i++)
combination[i] = multipleSuppliers[i][0].getSelectedSupplierIndex();
@@ -621,9 +612,11 @@ public class ResolverImpl implements org.eclipse.osgi.service.resolver.Resolver
// now iterate over every possible combination until either zero conflicts are found
// or we have run out of combinations
// if all combinations are tried then return the combination with the lowest number of conflicts
+ long initialTime = System.currentTimeMillis();
+ long timeLimit = Math.min(MAX_USES_TIME_BASE + (bundles.length * 30), MAX_USES_TIME_LIMIT);
int bestConflictCount = getConflictCount(bestConflicts);
ResolverBundle[] bestConflictBundles = getConflictedBundles(bestConflicts);
- while (bestConflictCount != 0 && getNextCombination(multipleSuppliers)) {
+ while (bestConflictCount != 0 && (System.currentTimeMillis() - initialTime) < timeLimit && getNextCombination(multipleSuppliers)) {
if (DEBUG_GROUPING)
printCombination(getCombination(multipleSuppliers, new int[multipleSuppliers.length]));
// first count the conflicts for the bundles with conflicts from the best combination

Back to the top