Skip to content

lock.py: fix Exception handling#2065

Open
sandy-lcq wants to merge 1 commit intorpm-software-management:masterfrom
sandy-lcq:master
Open

lock.py: fix Exception handling#2065
sandy-lcq wants to merge 1 commit intorpm-software-management:masterfrom
sandy-lcq:master

Conversation

@sandy-lcq
Copy link
Copy Markdown

Before, when logdir is not writable, _try_lock will raise an Exception like "Permission denied: '/var/log/log_lock.pid'", and in this case, _unlock_thread will not be called and the variable count will not be handled, it maybe cause log_lock.pid not be deleted in case like [1].

For [1], it is an cross compile case, when dnf install some packages to rootfs, seems like some threads don't do chroot like work, some threads do chroot like work. so for the threads don't do chroot, "Permission denied" Exception happend, for the threads that do chroot, log_lock.pid will be created under installroot/var/log/log_lock.pid, since variable count not handled correct before, log_lock.pid may not be deleted correctly.

So fixed like this, if _try_lock raise Exception, _unlock_thread first, then raise the Exception.

[1] #1963

Before, when logdir is not writable, _try_lock will raise an Exception
like "Permission denied: '/var/log/log_lock.pid'", and in this case,
_unlock_thread will not be called and the variable count will not be
handled, it maybe cause log_lock.pid not be deleted in case like [1].

For [1], it is an cross compile case, when dnf install some packages to
rootfs, seems like some threads don't do chroot like work, some threads
do chroot like work. so for the threads don't do chroot, "Permission denied"
Exception happend, for the threads that do chroot, log_lock.pid will be
created under installroot/var/log/log_lock.pid, since variable count not
handled correct before, log_lock.pid may not be deleted correctly.

So fixed like this, if _try_lock raise Exception, _unlock_thread first,
then raise the Exception.

[1] rpm-software-management#1963

Signed-off-by: Changqing Li <changqing.li@windriver.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant