forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland (3rd try): Lazily initialize MessageLoop for faster thread sta…
…rtup Original review: https://codereview.chromium.org/1011683002/ 2nd try: https://codereview.chromium.org/1129953004/ 2nd try reverted due to race reports on Linux: https://crbug.com/489263 Data races on valid_thread_id_ after r330329 This fixes: - Race in MessageLoopProxyImpl by introducing lock - Race in BrowserMainLoop/BrowserThreadImpl, where BrowserThread::CurrentlyOn() called on one of BrowserThreads tries to touch other thread's message_loop() via global thread table. Reg: the latter race, the code flow that causes this race is like following: // On the main thread, we create all known browser threads: for (...) { { AutoLock lock(g_lock); g_threads[id] = new BrowserProcessSubThread(); } // [A] This initializes the thread's message_loop, which causes a race // against [B] in the new code because new threads can start running // immediately. thread->StartWithOptions(); } // On the new thread's main function, it calls CurrentlyOn() which does: { // [B] This touches other thread's Thread::message_loop. AutoLock lock(g_lock); return g_threads[other_thread_id] && g_threads[other_thread_id]->message_loop() == MessageLoop::current(); } This was safe before because both message_loop initialization and the first call to CurrentlyOn() on the new thread was done synchronously in StartWithOptions() while the main thread was blocked. In the new code new threads can start accessing message_loop() asynchronously while the main thread's for loop is running. PS1 is the original patch (2nd try) that got reverted. BUG=465458, 489263 Review URL: https://codereview.chromium.org/1131513007 Cr-Commit-Position: refs/heads/master@{#331235}
- Loading branch information
Showing
25 changed files
with
300 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.