* [PATCH 0/1] runqemu: acquire_lock() should fail when failed to open the file
@ 2016-09-19 7:20 Robert Yang
2016-09-19 7:20 ` [PATCH 1/1] " Robert Yang
0 siblings, 1 reply; 2+ messages in thread
From: Robert Yang @ 2016-09-19 7:20 UTC (permalink / raw)
To: openembedded-core
The following changes since commit d77fe838ab7631a19e90ff4226f0712e54aa4e22:
scripts: add tool to scan for bashisms recipe shell scripts (2016-09-16 15:19:31 +0100)
are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib rbt/rq_lock
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=rbt/rq_lock
Robert Yang (1):
runqemu: acquire_lock() should fail when failed to open the file
scripts/runqemu | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--
2.9.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/1] runqemu: acquire_lock() should fail when failed to open the file
2016-09-19 7:20 [PATCH 0/1] runqemu: acquire_lock() should fail when failed to open the file Robert Yang
@ 2016-09-19 7:20 ` Robert Yang
0 siblings, 0 replies; 2+ messages in thread
From: Robert Yang @ 2016-09-19 7:20 UTC (permalink / raw)
To: openembedded-core
The open(self.lock, 'w') may fail when the lock is created by other
users, return false for this case to let it try other devices.
Fixed:
runqemu - INFO - Running /sbin/ip link...
runqemu - INFO - Acquiring lockfile /tmp/qemu-tap-locks/tap0.lock...
Traceback (most recent call last):
File "/buildarea/lyang1/poky/scripts/runqemu", line 972, in <module>
ret = main()
File "/buildarea/lyang1/poky/scripts/runqemu", line 963, in main
config.setup_network()
File "/buildarea/lyang1/poky/scripts/runqemu", line 810, in setup_network
self.setup_tap()
File "/buildarea/lyang1/poky/scripts/runqemu", line 761, in setup_tap
if self.acquire_lock():
File "/buildarea/lyang1/poky/scripts/runqemu", line 182, in acquire_lock
lock_descriptor = open(self.lock, 'w')
PermissionError: [Errno 13] Permission denied: '/tmp/qemu-tap-locks/tap0.lock'
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
scripts/runqemu | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/runqemu b/scripts/runqemu
index b6bc0ba..3805685 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -168,14 +168,14 @@ class BaseConfig(object):
def acquire_lock(self):
logger.info("Acquiring lockfile %s..." % self.lock)
- lock_descriptor = open(self.lock, 'w')
try:
- fcntl.flock(lock_descriptor, fcntl.LOCK_EX|fcntl.LOCK_NB)
+ self.lock_descriptor = open(self.lock, 'w')
+ fcntl.flock(self.lock_descriptor, fcntl.LOCK_EX|fcntl.LOCK_NB)
except Exception as e:
logger.info("Acquiring lockfile %s failed: %s" % (self.lock, e))
- lock_descriptor.close()
+ if self.lock_descriptor:
+ self.lock_descriptor.close()
return False
- self.lock_descriptor = lock_descriptor
return True
def release_lock(self):
--
2.9.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-19 7:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-19 7:20 [PATCH 0/1] runqemu: acquire_lock() should fail when failed to open the file Robert Yang
2016-09-19 7:20 ` [PATCH 1/1] " Robert Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox