Limit long slot conflict loop for bug #410801.
authorZac Medico <zmedico@gentoo.org>
Thu, 5 Apr 2012 19:37:40 +0000 (12:37 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 5 Apr 2012 19:37:40 +0000 (12:37 -0700)
pym/_emerge/resolver/slot_collision.py

index 1d522aabd61e7e2d501e5c30f3b8a8200c5e8cdc..a1c87146c8a9a13f1c660844273599be1489c5bc 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Gentoo Foundation
+# Copyright 2010-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
@@ -80,6 +80,8 @@ class slot_conflict_handler(object):
        the needed USE changes and prepare the message for the user.
        """
 
+       _check_configuration_max = 1024
+
        def __init__(self, depgraph):
                self.depgraph = depgraph
                self.myopts = depgraph._frozen_config.myopts
@@ -663,14 +665,24 @@ class slot_conflict_handler(object):
 
                solutions = []
                sol_gen = _solution_candidate_generator(all_involved_flags)
-               while(True):
+               checked = 0
+               while True:
                        candidate = sol_gen.get_candidate()
                        if not candidate:
                                break
                        solution = self._check_solution(config, candidate, all_conflict_atoms_by_slotatom)
+                       checked += 1
                        if solution:
                                solutions.append(solution)
-               
+
+                       if checked >= self._check_configuration_max:
+                               # TODO: Implement early elimination for candidates that would
+                               # change forced or masked flags, and don't count them here.
+                               if self.debug:
+                                       writemsg("\nAborting _check_configuration due to "
+                                               "excessive number of candidates.\n", noiselevel=-1)
+                               break
+
                if self.debug:
                        if not solutions:
                                writemsg("No viable solutions. Rejecting configuration.\n", noiselevel=-1)