From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1709833-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id B13EE15813A
	for <garchives@archives.gentoo.org>; Thu, 16 Jan 2025 21:04:52 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id F1B3BE07A5;
	Thu, 16 Jan 2025 21:04:51 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id D1A31E07A5
	for <gentoo-commits@lists.gentoo.org>; Thu, 16 Jan 2025 21:04:51 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id D802B343194
	for <gentoo-commits@lists.gentoo.org>; Thu, 16 Jan 2025 21:04:50 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 37AF11F9A
	for <gentoo-commits@lists.gentoo.org>; Thu, 16 Jan 2025 21:04:49 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1737061486.77342028d27293fd274c974f72a7d5d303c45517.sam@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: lib/_emerge/
X-VCS-Repository: proj/portage
X-VCS-Files: lib/_emerge/Scheduler.py
X-VCS-Directories: lib/_emerge/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 77342028d27293fd274c974f72a7d5d303c45517
X-VCS-Branch: master
Date: Thu, 16 Jan 2025 21:04:49 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 37345a2b-896e-4076-9a1e-365a4c9b6eef
X-Archives-Hash: c852c0c8990075c3e71fed00185d7d09

commit:     77342028d27293fd274c974f72a7d5d303c45517
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 27 18:58:59 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jan 16 21:04:46 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=77342028

Flush the merge-wait queue on SIGUSR2

If portage receives SIGUSR2, then flush the merge-wait queue on the
next possible occasion (typically after all running "install" jobs
are finished).

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/1406
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/_emerge/Scheduler.py | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/lib/_emerge/Scheduler.py b/lib/_emerge/Scheduler.py
index 96843c96ee..7d9023b0b9 100644
--- a/lib/_emerge/Scheduler.py
+++ b/lib/_emerge/Scheduler.py
@@ -210,6 +210,8 @@ class Scheduler(PollScheduler):
         # empty.
         self._merge_wait_scheduled = []
 
+        self._flush_merge_wait_queue = False
+
         # Holds system packages and their deep runtime dependencies. Before
         # being merged, these packages go to merge_wait_queue, to be merged
         # when no other packages are building.
@@ -1170,12 +1172,16 @@ class Scheduler(PollScheduler):
                 self.terminate()
                 received_signal.append(128 + signum)
 
+            def sigusr2handler(signum, frame):
+                self._flush_merge_wait_queue = True
+
             earlier_sigint_handler = signal.signal(signal.SIGINT, sighandler)
             earlier_sigterm_handler = signal.signal(signal.SIGTERM, sighandler)
             earlier_sigcont_handler = signal.signal(
                 signal.SIGCONT, self._sigcont_handler
             )
             signal.siginterrupt(signal.SIGCONT, False)
+            earlier_sigusr2_handler = signal.signal(signal.SIGUSR2, sigusr2handler)
 
             earlier_sigwinch_handler = signal.signal(
                 signal.SIGWINCH, self._sigwinch_handler
@@ -1196,6 +1202,10 @@ class Scheduler(PollScheduler):
                     signal.signal(signal.SIGCONT, earlier_sigcont_handler)
                 else:
                     signal.signal(signal.SIGCONT, signal.SIG_DFL)
+                if earlier_sigusr2_handler is not None:
+                    signal.signal(signal.SIGUSR2, earlier_sigusr2_handler)
+                else:
+                    signal.signal(signal.SIGUSR2, signal.SIG_DFL)
 
                 if earlier_sigwinch_handler is not None:
                     signal.signal(signal.SIGWINCH, earlier_sigwinch_handler)
@@ -1817,11 +1827,16 @@ class Scheduler(PollScheduler):
             # special packages and we want to ensure that
             # parallel-install does not cause more than one of
             # them to install at the same time.
-            if (
-                self._merge_wait_queue
-                and not self._jobs
-                and not self._task_queues.merge
+            if self._merge_wait_queue and (
+                (not self._jobs and not self._task_queues.merge)
+                or self._flush_merge_wait_queue
             ):
+                if self._flush_merge_wait_queue:
+                    self._status_msg(
+                        "Manual flush of the merge-wait queue requested (e.g., via SIGUSR2)"
+                    )
+                    self._flush_merge_wait_queue = False
+
                 while self._merge_wait_queue:
                     # If we added non-system packages to the merge queue in a
                     # previous iteration of this loop, then for system packages we