Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Issue 4721001: Add multi_process_lock to chrome/common (Closed)

Created:
10 years, 1 month ago by dmac
Modified:
9 years, 7 months ago
CC:
chromium-reviews, Paweł Hajdan Jr., pam+watch_chromium.org, brettw-cc_chromium.org
Visibility:
Public.

Description

Add multi_process_lock to base Platform abstraction for a shared lock between processes. The process that owns the lock will release it on exit even if exit is due to a crash. For cloud-print and remoting we want to be able to have a singleton service-process that can run independently of the browser process. This service process will communicate with the browser process via the standard IAC channels, but we want to have a way of signaling to other processes that a) there is a service-process running and b) that it is in a state where it is ready to be communicated with. The multi_process_lock class is intended to work as a simple flag that can be queried from multiple processes. If the service-process should crash, we would like the flag to be cleared automatically so that there is never confusion about the state of the service-process. Other approaches considered for some Unix/Mac: - Standard unix domain sockets depend on the file system and don't clean up properly in the case of a crash. - Shared memory on unix depend on the file system and don't clean up properly in the case of a crash. - System V semaphores on unix again depend on the file system. - named_mach_ports on Mac OS. Bootstrap_register_name has been deprecated on 10.6, so we are doing essentially the same thing using CFMessagePort. On Windows it is implemented as an event. On Mac it is implemented using a CFMessagePort name. On Linux it is implement using an abstract name port socket. TEST=none BUG=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=66323

Patch Set 1 #

Total comments: 61

Patch Set 2 : Fixing up issues. #

Patch Set 3 : fixed up some more style issues #

Patch Set 4 : get rid of change to base.gypi #

Patch Set 5 : Fix up linux compile errors #

Patch Set 6 : removed long name test as it tripped a NOTREACHED call. #

Total comments: 12

Patch Set 7 : fix up comments and make recursive #

Patch Set 8 : fix up leak of windows handle #

Patch Set 9 : forced the over unlock case #

Total comments: 12

Patch Set 10 : Got rid of recursion, fixed up linux bind call #

Patch Set 11 : fix up silly linux compile issue #

Total comments: 14

Patch Set 12 : Fixed up based on comments #

Patch Set 13 : add some randomization to the test #

Patch Set 14 : Clean up missing static value, and clean up stream usage. #

Patch Set 15 : fix up unittest on linux #

Patch Set 16 : Added missing struct keyword #

Patch Set 17 : Fix up missing inttypes.h problem on Windows #

Patch Set 18 : Realized that the whole static fix wasn't going to work, and revamped. #

Patch Set 19 : Fix up linux not compiling #

Total comments: 26

Patch Set 20 : more clean up for mento #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+456 lines, -0 lines) Patch
M chrome/chrome_common.gypi View 2 3 4 5 6 7 8 9 10 11 1 chunk +4 lines, -0 lines 0 comments Download
M chrome/chrome_tests.gypi View 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
A chrome/common/multi_process_lock.h View 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +39 lines, -0 lines 1 comment Download
A chrome/common/multi_process_lock_linux.cc View 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +95 lines, -0 lines 0 comments Download
A chrome/common/multi_process_lock_mac.cc View 2 3 4 5 6 7 8 9 10 11 1 chunk +54 lines, -0 lines 0 comments Download
A chrome/common/multi_process_lock_unittest.cc View 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +205 lines, -0 lines 2 comments Download
A chrome/common/multi_process_lock_win.cc View 2 3 4 5 6 7 8 9 10 11 12 1 chunk +58 lines, -0 lines 0 comments Download

Messages

Total messages: 41 (0 generated)
dmac
sanjeev, I'm hoping you will look at the windows side. Evan, I'm hoping you will ...
10 years, 1 month ago (2010-11-08 22:55:19 UTC) #1
Evan Martin
HTTP 302 Better Linux Reviewer Location: agl@chromium.org
10 years, 1 month ago (2010-11-08 23:01:18 UTC) #2
agl
This change needs a significantly expanded motivation in the description before it can be reviewed.
10 years, 1 month ago (2010-11-08 23:14:05 UTC) #3
dmac
On 2010/11/08 23:14:05, agl wrote: > This change needs a significantly expanded motivation in the ...
10 years, 1 month ago (2010-11-08 23:38:53 UTC) #4
agl
Thanks for the motivation. I'm worried about the name "SharedMutex". It's similar to the ProcessSingleton ...
10 years, 1 month ago (2010-11-08 23:57:49 UTC) #5
sanjeevr
Some overall comments: 1. I agree with agl about the name. Especially because mutex means ...
10 years, 1 month ago (2010-11-09 06:21:05 UTC) #6
TVL
+mark as the one that keeps an eye on base for Mac. General comment - ...
10 years, 1 month ago (2010-11-09 13:19:01 UTC) #7
sanjeevr
I can comment about the name. It is essentially a unique way of identifying this ...
10 years, 1 month ago (2010-11-09 15:54:54 UTC) #8
dmac
On 2010/11/08 23:57:49, agl wrote: > Thanks for the motivation. > > I'm worried about ...
10 years, 1 month ago (2010-11-09 17:28:17 UTC) #9
agl
On Tue, Nov 9, 2010 at 12:28 PM, <dmaclach@chromium.org> wrote: > I was actually considering ...
10 years, 1 month ago (2010-11-09 17:37:15 UTC) #10
Mark Mentovai
I don’t like SharedMutex or really anything with Shared in the name either. http://codereview.chromium.org/4721001/diff/1/4 File ...
10 years, 1 month ago (2010-11-09 17:43:12 UTC) #11
brettw
To what extent do people think this belongs in base? This seems like kind of ...
10 years, 1 month ago (2010-11-09 17:44:15 UTC) #12
sanjeevr
I would be OK with this living in chrome/common. On Tue, Nov 9, 2010 at ...
10 years, 1 month ago (2010-11-09 17:45:29 UTC) #13
Evan Martin
On Tue, Nov 9, 2010 at 9:28 AM, <dmaclach@chromium.org> wrote: > I was actually considering ...
10 years, 1 month ago (2010-11-09 17:53:00 UTC) #14
sanjeevr
Evan, the name that is used is derived from the user_data_dir, so this *can* be ...
10 years, 1 month ago (2010-11-09 17:56:01 UTC) #15
brettw
In other places in Chrome, we use a named pipe for communication. If the pipe ...
10 years, 1 month ago (2010-11-09 19:17:18 UTC) #16
dmac
On 2010/11/09 19:17:18, brettw wrote: > In other places in Chrome, we use a named ...
10 years, 1 month ago (2010-11-11 00:13:48 UTC) #17
dmac
On 2010/11/09 17:37:15, agl wrote: > On Tue, Nov 9, 2010 at 12:28 PM, <mailto:dmaclach@chromium.org> ...
10 years, 1 month ago (2010-11-11 00:16:05 UTC) #18
sanjeevr
I am OK with MultiProcessLock. I am also OK with the code being in chrome/common. ...
10 years, 1 month ago (2010-11-11 05:03:30 UTC) #19
Mark Mentovai
dmaclach@chromium.org wrote: > Is there anyone unhappy with MultiProcessLock? and by unhappy I mean you ...
10 years, 1 month ago (2010-11-11 20:29:14 UTC) #20
dmac
Performed rename and cleaned up issues. Running through try bots now. http://codereview.chromium.org/4721001/diff/1/base/shared_mutex.h File base/shared_mutex.h (right): ...
10 years, 1 month ago (2010-11-11 21:47:59 UTC) #21
agl
LGTM for Linux http://codereview.chromium.org/4721001/diff/33001/chrome/common/multi_process_lock_linux.cc File chrome/common/multi_process_lock_linux.cc (right): http://codereview.chromium.org/4721001/diff/33001/chrome/common/multi_process_lock_linux.cc#newcode23 chrome/common/multi_process_lock_linux.cc:23: // +2 because: 1 for terminator, ...
10 years, 1 month ago (2010-11-11 21:50:53 UTC) #22
sanjeevr
Are you planning to change the interface to be tri-state? (not running, running-not-ready and running-ready) ...
10 years, 1 month ago (2010-11-11 22:06:56 UTC) #23
Mark Mentovai
http://codereview.chromium.org/4721001/diff/33001/chrome/common/multi_process_lock.h File chrome/common/multi_process_lock.h (right): http://codereview.chromium.org/4721001/diff/33001/chrome/common/multi_process_lock.h#newcode24 chrome/common/multi_process_lock.h:24: virtual bool TryLock() = 0; Once you write “virtual” ...
10 years, 1 month ago (2010-11-11 22:08:27 UTC) #24
Mark Mentovai
I wrote: > http://codereview.chromium.org/4721001/diff/33001/chrome/common/multi_process_lock.h#newcode33 > chrome/common/multi_process_lock.h:33: }; > #include "base/basictypes.h" > [...] > private: > ...
10 years, 1 month ago (2010-11-11 22:15:26 UTC) #25
brettw
Hooray for chrome/common. Thanks for finding away to avoid adding to base.
10 years, 1 month ago (2010-11-11 22:21:47 UTC) #26
Mark Mentovai
Also, I’m not sure if you considered this, but: Not being able to allocate objects ...
10 years, 1 month ago (2010-11-11 22:55:28 UTC) #27
dmaclach1
On Thu, Nov 11, 2010 at 2:55 PM, <mark@chromium.org> wrote: > Also, I’m not sure ...
10 years, 1 month ago (2010-11-11 22:58:50 UTC) #28
dmac
On 2010/11/11 22:06:56, sanjeevr wrote: > Are you planning to change the interface to be ...
10 years, 1 month ago (2010-11-11 23:13:07 UTC) #29
dmac
Also made lock recursive. http://codereview.chromium.org/4721001/diff/33001/chrome/common/multi_process_lock.h File chrome/common/multi_process_lock.h (right): http://codereview.chromium.org/4721001/diff/33001/chrome/common/multi_process_lock.h#newcode24 chrome/common/multi_process_lock.h:24: virtual bool TryLock() = 0; ...
10 years, 1 month ago (2010-11-11 23:33:02 UTC) #30
Mark Mentovai
I’m not in love with the proposed design of the recursive stuff considering the duplication. ...
10 years, 1 month ago (2010-11-11 23:45:24 UTC) #31
dmac
http://codereview.chromium.org/4721001/diff/49001/chrome/common/multi_process_lock_mac.cc File chrome/common/multi_process_lock_mac.cc (right): http://codereview.chromium.org/4721001/diff/49001/chrome/common/multi_process_lock_mac.cc#newcode14 chrome/common/multi_process_lock_mac.cc:14: : name_(name), count_(0) { } On 2010/11/11 23:45:24, Mark ...
10 years, 1 month ago (2010-11-12 00:36:26 UTC) #32
sanjeevr
LGTM for the Windows code with a nit. http://codereview.chromium.org/4721001/diff/49002/chrome/common/multi_process_lock_win.cc File chrome/common/multi_process_lock_win.cc (right): http://codereview.chromium.org/4721001/diff/49002/chrome/common/multi_process_lock_win.cc#newcode27 chrome/common/multi_process_lock_win.cc:27: HANDLE ...
10 years, 1 month ago (2010-11-12 17:47:56 UTC) #33
Mark Mentovai
Mac LGTM. Design LGTM. Test questions, and I’ll defer to Adam and Sanjeev for Linux ...
10 years, 1 month ago (2010-11-12 17:58:28 UTC) #34
dmac
Sorry for all the revisions. http://codereview.chromium.org/4721001/diff/49002/chrome/common/multi_process_lock_mac.cc File chrome/common/multi_process_lock_mac.cc (right): http://codereview.chromium.org/4721001/diff/49002/chrome/common/multi_process_lock_mac.cc#newcode34 chrome/common/multi_process_lock_mac.cc:34: DLOG(ERROR) << "Over unlocked ...
10 years, 1 month ago (2010-11-15 23:02:13 UTC) #35
Mark Mentovai
This is pretty good. I think these are the only things that remain. http://codereview.chromium.org/4721001/diff/75001/chrome/common/multi_process_lock.h File ...
10 years, 1 month ago (2010-11-15 23:42:54 UTC) #36
dmac
http://codereview.chromium.org/4721001/diff/75001/chrome/common/multi_process_lock_linux.cc File chrome/common/multi_process_lock_linux.cc (right): http://codereview.chromium.org/4721001/diff/75001/chrome/common/multi_process_lock_linux.cc#newcode37 chrome/common/multi_process_lock_linux.cc:37: memset(&address, 0, sizeof(address)); On 2010/11/15 23:42:55, Mark Mentovai wrote: ...
10 years, 1 month ago (2010-11-15 23:55:23 UTC) #37
Mark Mentovai
http://codereview.chromium.org/4721001/diff/75001/chrome/common/multi_process_lock_unittest.cc File chrome/common/multi_process_lock_unittest.cc (right): http://codereview.chromium.org/4721001/diff/75001/chrome/common/multi_process_lock_unittest.cc#newcode18 chrome/common/multi_process_lock_unittest.cc:18: static char kMutexName[] = "shared_mutex_unittest " __DATE__ " " ...
10 years, 1 month ago (2010-11-16 04:05:50 UTC) #38
dmac
OK, added some getenv/setenv functions. Will move those over to process_utils in a separate change. ...
10 years, 1 month ago (2010-11-16 17:54:16 UTC) #39
Mark Mentovai
LGTM! http://codereview.chromium.org/4721001/diff/84001/chrome/common/multi_process_lock.h File chrome/common/multi_process_lock.h (right): http://codereview.chromium.org/4721001/diff/84001/chrome/common/multi_process_lock.h#newcode9 chrome/common/multi_process_lock.h:9: #include <string> C++ headers should follow C headers. ...
10 years, 1 month ago (2010-11-16 18:55:14 UTC) #40
avi_google.com
10 years, 1 month ago (2010-11-16 22:07:29 UTC) #41
http://codereview.chromium.org/4721001/diff/84001/chrome/common/multi_process...
File chrome/common/multi_process_lock_unittest.cc (right):

http://codereview.chromium.org/4721001/diff/84001/chrome/common/multi_process...
chrome/common/multi_process_lock_unittest.cc:186: // are perusing thge build
logs.
drive-by typo: thge

Powered by Google App Engine
This is Rietveld 408576698