Closed Bug 1719577 Opened 4 years ago Closed 4 years ago

Clean up locking in MessageChannel

Categories

(Core :: IPC, task)

task

Tracking

()

RESOLVED FIXED
92 Branch
Tracking Status
firefox92 --- fixed

People

(Reporter: nika, Assigned: nika)

Details

Attachments

(8 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
No description provided.

This makes things generally more clear, and avoids a long list of initializers
in the MessageChannel constructor. In addition, some fields which are never
modified are marked as const.

Now that PortLink is the only MessageLink implementation, it is no longer
necessary to support sharing a single RefCountedMonitor between multiple
MessageChannels, meaning that we can construct the monitor directly in the
MessageChannel constructor. The monitor still needs to be refcounted due to
being used by the PortLink as part of the listener implementation.

This simplifies some of the reasoning about when to hold locks by holding it
when setting all monitor-guarded fields.

This state was only used by the ProcessLink MessageLink implementation, and no
longer exists with the new PortLink implementation, so can be removed.

This should make the logic around clearing a MessageChannel more obviously
correct by holding the mutex when accessing fields which are traditionally
guarded by the mutex. These lock calls shouldn't introduce performance issues
as the lock should be uncontended.

This comment refers to the old ProcessLink implementation, and was missed when
that implementation was removed.

Attachment #9230191 - Attachment description: Bug 1719577 - Part 1: Use inline initializers for MessageChannel fields, → Bug 1719577 - Part 1: Use inline initializers for MessageChannel fields, r=handyman
Attachment #9230192 - Attachment description: Bug 1719577 - Part 2: Create mMonitor eagerly in MessageChannel's constructor, → Bug 1719577 - Part 2: Create mMonitor eagerly in MessageChannel's constructor, r=handyman
Attachment #9230193 - Attachment description: Bug 1719577 - Part 3: Remove dead WaitForIncomingMessage function, → Bug 1719577 - Part 3: Remove dead WaitForIncomingMessage function, r=handyman
Attachment #9230194 - Attachment description: Bug 1719577 - Part 4: Hold the monitor for more of `MessageChannel::Open`, → Bug 1719577 - Part 4: Hold the monitor for more of `MessageChannel::Open`, r=handyman
Attachment #9230195 - Attachment description: Bug 1719577 - Part 5: Remove the now-unused `ChannelOpening` state, → Bug 1719577 - Part 5: Remove the now-unused `ChannelOpening` state, r=handyman
Attachment #9230196 - Attachment description: Bug 1719577 - Part 6: More consistently use the monitor during MessageChannel shutdown, → Bug 1719577 - Part 6: More consistently use the monitor during MessageChannel shutdown, r=handyman
Attachment #9230197 - Attachment description: Bug 1719577 - Part 7: Remove outdated comment, → Bug 1719577 - Part 7: Remove outdated comment, r=handyman
Attachment #9230198 - Attachment description: Bug 1719577 - Part 8: Remove some unused methods from MessageChannel, → Bug 1719577 - Part 8: Remove some unused methods from MessageChannel, r=handyman
Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b7c5eb05364c Part 1: Use inline initializers for MessageChannel fields, r=handyman https://hg.mozilla.org/integration/autoland/rev/68e1d5aaf856 Part 2: Create mMonitor eagerly in MessageChannel's constructor, r=handyman https://hg.mozilla.org/integration/autoland/rev/6c7b991eb21d Part 3: Remove dead WaitForIncomingMessage function, r=handyman https://hg.mozilla.org/integration/autoland/rev/cc1b04b6f68c Part 4: Hold the monitor for more of `MessageChannel::Open`, r=handyman https://hg.mozilla.org/integration/autoland/rev/bb78618b5c81 Part 5: Remove the now-unused `ChannelOpening` state, r=handyman https://hg.mozilla.org/integration/autoland/rev/105c1a4bebae Part 6: More consistently use the monitor during MessageChannel shutdown, r=handyman https://hg.mozilla.org/integration/autoland/rev/1b5b806c2f73 Part 7: Remove outdated comment, r=handyman https://hg.mozilla.org/integration/autoland/rev/766d12d3f3fe Part 8: Remove some unused methods from MessageChannel, r=handyman
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: