From 537c8c3c175e89c19e779170757412d8a04dd8a72db8bfc0671d2b63c609c2ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ismail=20D=C3=B6nmez?= Date: Fri, 15 Aug 2014 11:48:58 +0000 Subject: [PATCH] Accepting request 244786 from home:mcaj:branches:Base:System - I wrote a patch got-lock.patch to fix the trouble with the got-lock variable.I was testing the withlock and still had there the lock file after a program already end with exit code 0. I have look on the code together with our Python expert mvidner@suse.cz and we found the got-lock variable isn't marked ad global variable. We have tested it and with the patch the program is working very well. I send this patch also to upstream (poeml@cmdline.net) OBS-URL: https://build.opensuse.org/request/show/244786 OBS-URL: https://build.opensuse.org/package/show/Base:System/withlock?expand=0&rev=8 --- got-lock.patch | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ withlock.changes | 10 +++++++++ withlock.spec | 6 +++++- 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 got-lock.patch diff --git a/got-lock.patch b/got-lock.patch new file mode 100644 index 0000000..4e0da23 --- /dev/null +++ b/got-lock.patch @@ -0,0 +1,56 @@ +Index: withlock-0.3/withlock +=================================================================== +--- withlock-0.3.orig/withlock ++++ withlock-0.3/withlock +@@ -64,12 +64,21 @@ for name in 'SIGBREAK', 'SIGHUP', 'SIGTE + if num: signal.signal(num, catchterm) + + +-def cleanup(lockfile): ++def cleanup(lockfile, verbose): ++ global got_lock ++ if verbose: ++ sys.stderr.write('got_lock is set to: %r\n' % got_lock) ++ ++ if verbose: ++ sys.stderr.write('removing lockfile: %r\n' % lockfile) ++ + if got_lock: + try: + os.unlink(lockfile) + except: + pass ++ else: ++ sys.stderr.write('the lockfile was not removed !\n') + + + def main(): +@@ -132,6 +141,7 @@ def main(): + + lock = open(lockfile, 'w') + ++ global got_lock + while 1 + 1 == 2: + + try: +@@ -174,7 +184,7 @@ def main(): + % lockfile) + + +- atexit.register(cleanup, lockfile) ++ atexit.register(cleanup, lockfile, options.verbose) + os.umask(prev_umask) + + import subprocess +@@ -184,10 +194,7 @@ def main(): + + if options.verbose: + sys.stderr.write('command terminated with exit code %s\n' % rc) +- +- if options.verbose: +- sys.stderr.write('removing lockfile\n') +- ++ + sys.exit(rc) + + diff --git a/withlock.changes b/withlock.changes index 4388e90..4e5c316 100644 --- a/withlock.changes +++ b/withlock.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Thu Aug 14 13:23:11 UTC 2014 - mcaj@suse.com + +- I wrote a patch got-lock.patch to fix the trouble with the got-lock variable. + I was testing the withlock and still had there the lock file after a + program already end with exit code 0. I have look on the code together + with our Python expert mvidner@suse.cz and we found the got-lock variable + isn't marked ad global variable.I`ll send this to poeml@cmdline.net + after we test it on our servers. + ------------------------------------------------------------------- Tue Mar 25 21:07:09 UTC 2014 - poeml@cmdline.net diff --git a/withlock.spec b/withlock.spec index a0bdddf..63d673e 100644 --- a/withlock.spec +++ b/withlock.spec @@ -26,6 +26,8 @@ Url: http://code.google.com/p/withlock/ Requires: python Source0: http://mirrorbrain.org/files/releases/%{name}-%{version}.tar.gz Source1: %name-README.SuSE +# fixed trouble with not removed lock file bacuse got-lock was not global variable. +Patch0: got-lock.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch @@ -40,7 +42,9 @@ to use, and much better than implementing half-hearted locking within scripts. %prep %setup -# + +%patch0 -p1 + %build # %install