Merge lp:~cmiller/ubuntu/lucid/desktopcouch/lp726597 into lp:ubuntu/lucid-proposed/desktopcouch

Proposed by Chad Miller
Status: Merged
Merged at revision: 23
Proposed branch: lp:~cmiller/ubuntu/lucid/desktopcouch/lp726597
Merge into: lp:ubuntu/lucid-proposed/desktopcouch
Diff against target: 85 lines (+73/-0)
2 files modified
debian/changelog (+7/-0)
debian/patches/lp_726597.patch (+66/-0)
To merge this branch: bzr merge lp:~cmiller/ubuntu/lucid/desktopcouch/lp726597
Reviewer Review Type Date Requested Status
Ubuntu Stable Release Updates Team Pending
Ubuntu Development Team Pending
Review via email: mp+52897@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2010-09-19 20:18:04 +0000
+++ debian/changelog 2011-03-10 18:17:44 +0000
@@ -1,3 +1,10 @@
1desktopcouch (0.6.4-0ubuntu3.2) lucid-proposed; urgency=low
2
3 * Add debian/patches/lp_726597.patch
4 - Avoid race for startup of couchdb (LP: #726597)
5
6 -- Chad MILLER <chad.miller@canonical.com> Thu, 03 Mar 2011 11:06:01 -0500
7
1desktopcouch (0.6.4-0ubuntu3.1) lucid-proposed; urgency=low8desktopcouch (0.6.4-0ubuntu3.1) lucid-proposed; urgency=low
29
3 * Add gnome-keyring to depends of python-desktopcouch (LP: #565376)10 * Add gnome-keyring to depends of python-desktopcouch (LP: #565376)
411
=== added file 'debian/patches/lp_726597.patch'
--- debian/patches/lp_726597.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/lp_726597.patch 2011-03-10 18:17:44 +0000
@@ -0,0 +1,66 @@
1Description: Avoid a race to find and start a new couchdb.
2Origin: Upstream
3Author: Roman Yepishev <roman.yepishev@canonical.com>
4Bug-Ubuntu: https://bugs.launchpad.net/726597
5Forwarded: not-needed
6
7=== modified file 'desktopcouch/__init__.py'
8--- old/desktopcouch/__init__.py 2010-03-10 22:18:24 +0000
9+++ new/desktopcouch/__init__.py 2011-02-23 22:58:49 +0000
10@@ -20,7 +20,8 @@
11 from desktopcouch.start_local_couchdb import process_is_couchdb, read_pidfile
12 import dbus
13 import logging
14-
15+import time
16+from fcntl import flock, LOCK_EX, LOCK_NB
17
18 def find_pid(start_if_not_running=True, ctx=local_files.DEFAULT_CONTEXT):
19 """Find the current OS process ID of the running couchdb. API users
20@@ -30,11 +31,26 @@
21 if not process_is_couchdb(pid):
22 if start_if_not_running:
23 # start CouchDB by running the startup script
24- logging.info("Desktop CouchDB is not running; starting it.")
25- from desktopcouch import start_local_couchdb
26- pid = start_local_couchdb.start_couchdb(ctx=ctx)
27- # now load the design documents, because it's started
28- start_local_couchdb.update_design_documents()
29+ # we check the lock, if some process holds the lock then we will
30+ # merely wait for pifile to become meaningful
31+ try:
32+ ctx.lock_fd = open(ctx.file_lock, "w")
33+ flock(ctx.lock_fd, LOCK_EX | LOCK_NB)
34+ except IOError:
35+ logging.info("Another Desktop CouchDB is running. "
36+ "Waiting for PID.")
37+ pid = None
38+ for timeout in (0.4, 0.1, 0.1, 0.2, 0.5, 1, 3, 5):
39+ pid = read_pidfile(ctx=ctx)
40+ if pid is not None and process_is_couchdb(pid):
41+ break
42+ time.sleep(timeout)
43+ else:
44+ logging.info("Desktop CouchDB is not running; starting it.")
45+ from desktopcouch import start_local_couchdb
46+ pid = start_local_couchdb.start_couchdb(ctx=ctx)
47+ # now load the design documents, because it's started
48+ start_local_couchdb.update_design_documents()
49
50 if not process_is_couchdb(pid):
51 logging.error("CouchDB process did not start up")
52
53=== modified file 'desktopcouch/local_files.py'
54--- old/desktopcouch/local_files.py 2010-04-13 00:33:23 +0000
55+++ new/desktopcouch/local_files.py 2011-02-23 22:58:49 +0000
56@@ -228,6 +228,9 @@
57 self.file_stdout = os.path.join(run_dir, "desktop-couchdb.stdout")
58 self.file_stderr = os.path.join(run_dir, "desktop-couchdb.stderr")
59
60+ self.file_lock = os.path.join(run_dir, "desktop-couchdb.lock")
61+ self.lock_fd = None
62+
63 # You will need to add -b or -k on the end of this
64 self.couch_exec_command = [COUCH_EXE, self.couch_chain_ini_files(),
65 '-p', self.file_pid,
66

Subscribers

People subscribed via source and target branches

to all changes: