[oe-commits] [openembedded-core] 06/25: scripts/runqemu: Tidy up lock handling code
git at git.openembedded.org
git at git.openembedded.org
Sat Dec 1 11:46:00 UTC 2018
This is an automated email from the git hooks/post-receive script.
rpurdie pushed a commit to branch master
in repository openembedded-core.
commit 58e48211f7cb44d959b571d449a94291c27535a5
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Wed Nov 28 17:30:10 2018 +0000
scripts/runqemu: Tidy up lock handling code
Various tweaks:
- Balance up the aquire/release functions
- Use debug messge for both acquiring and release message for consistency in logs
- Use None instead of an empty string
- Reset the value of the field if we don't have the lock any more
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
scripts/runqemu | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/scripts/runqemu b/scripts/runqemu
index 3786646..d25de42 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -220,7 +220,7 @@ class BaseConfig(object):
self.tcpserial_portnum = ''
self.custombiosdir = ''
self.lock = ''
- self.lock_descriptor = ''
+ self.lock_descriptor = None
self.bitbake_e = ''
self.snapshot = False
self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs',
@@ -254,13 +254,17 @@ class BaseConfig(object):
logger.info(msg)
if self.lock_descriptor:
self.lock_descriptor.close()
+ self.lock_descriptor = None
return False
return True
def release_lock(self):
- fcntl.flock(self.lock_descriptor, fcntl.LOCK_UN)
- self.lock_descriptor.close()
- os.remove(self.lock)
+ if self.lock_descriptor:
+ logger.debug("Releasing lockfile for tap device '%s'" % self.tap)
+ fcntl.flock(self.lock_descriptor, fcntl.LOCK_UN)
+ self.lock_descriptor.close()
+ os.remove(self.lock)
+ self.lock_descriptor = None
def get(self, key):
if key in self.d:
@@ -1237,9 +1241,7 @@ class BaseConfig(object):
cmd = 'sudo %s %s %s' % (self.qemuifdown, self.tap, self.bindir_native)
logger.debug('Running %s' % cmd)
subprocess.check_call(cmd, shell=True)
- if self.lock_descriptor:
- logger.info("Releasing lockfile for tap device '%s'" % self.tap)
- self.release_lock()
+ self.release_lock()
if self.nfs_running:
logger.info("Shutting down the userspace NFS server...")
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list