public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] EbuildIpc.communicate: lockfile PermissionDenied retry
@ 2021-11-04  3:09 Zac Medico
  2021-11-07  4:58 ` [gentoo-portage-dev] " Zac Medico
  0 siblings, 1 reply; 2+ messages in thread
From: Zac Medico @ 2021-11-04  3:09 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Zac Medico

The lockfile function is expected to raise PermissionDenied if
the (root) parent process holds the lock, so retry in this case.

Bug: https://bugs.gentoo.org/468990
Signed-off-by: Zac Medico <zmedico@gentoo.org>
---
 bin/ebuild-ipc.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py
index 4999c043a..6eaa658a2 100755
--- a/bin/ebuild-ipc.py
+++ b/bin/ebuild-ipc.py
@@ -158,7 +158,16 @@ class EbuildIpc:
         # Make locks quiet since unintended locking messages displayed on
         # stdout could corrupt the intended output of this program.
         portage.locks._quiet = True
-        lock_obj = portage.locks.lockfile(self.ipc_lock_file, unlinkfile=True)
+        # Acquire lock with PermissionDenied retry for bug #468990.
+        for _ in range(1000):
+            try:
+                lock_obj = portage.locks.lockfile(self.ipc_lock_file, unlinkfile=True)
+            except portage.exception.PermissionDenied:
+                time.sleep(0.1)
+            else:
+                break
+        else:
+            raise portage.exception.PermissionDenied(self.ipc_lock_file)
 
         try:
             return self._communicate(args)
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-portage-dev] Re: [PATCH] EbuildIpc.communicate: lockfile PermissionDenied retry
  2021-11-04  3:09 [gentoo-portage-dev] [PATCH] EbuildIpc.communicate: lockfile PermissionDenied retry Zac Medico
@ 2021-11-07  4:58 ` Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2021-11-07  4:58 UTC (permalink / raw
  To: Zac Medico, gentoo-portage-dev


[-- Attachment #1.1: Type: text/plain, Size: 1532 bytes --]

On 11/3/21 20:09, Zac Medico wrote:
> The lockfile function is expected to raise PermissionDenied if
> the (root) parent process holds the lock, so retry in this case.
> 
> Bug: https://bugs.gentoo.org/468990
> Signed-off-by: Zac Medico <zmedico@gentoo.org>
> ---
>   bin/ebuild-ipc.py | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py
> index 4999c043a..6eaa658a2 100755
> --- a/bin/ebuild-ipc.py
> +++ b/bin/ebuild-ipc.py
> @@ -158,7 +158,16 @@ class EbuildIpc:
>           # Make locks quiet since unintended locking messages displayed on
>           # stdout could corrupt the intended output of this program.
>           portage.locks._quiet = True
> -        lock_obj = portage.locks.lockfile(self.ipc_lock_file, unlinkfile=True)
> +        # Acquire lock with PermissionDenied retry for bug #468990.
> +        for _ in range(1000):
> +            try:
> +                lock_obj = portage.locks.lockfile(self.ipc_lock_file, unlinkfile=True)
> +            except portage.exception.PermissionDenied:
> +                time.sleep(0.1)
> +            else:
> +                break
> +        else:
> +            raise portage.exception.PermissionDenied(self.ipc_lock_file)
>   
>           try:
>               return self._communicate(args)
> 

Withdrawn in favor of this lockfile permission race fix:

https://archives.gentoo.org/gentoo-portage-dev/message/88916062415d9f692091dfb947f1bda2
-- 
Thanks,
Zac

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-07  4:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-04  3:09 [gentoo-portage-dev] [PATCH] EbuildIpc.communicate: lockfile PermissionDenied retry Zac Medico
2021-11-07  4:58 ` [gentoo-portage-dev] " Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox