Merge pull request #11283 from electron/fix-event-subscriber-race
Fix race condition in event_subscriber.h
This commit is contained in:
commit
19f1fef040
1 changed files with 7 additions and 0 deletions
|
@ -73,6 +73,13 @@ class EventSubscriber : internal::EventSubscriberBase {
|
||||||
content::BrowserThread::UI, FROM_HERE,
|
content::BrowserThread::UI, FROM_HERE,
|
||||||
base::Bind(
|
base::Bind(
|
||||||
[](EventSubscriber<HandlerType>* subscriber) {
|
[](EventSubscriber<HandlerType>* subscriber) {
|
||||||
|
{
|
||||||
|
// It is possible that this function will execute in the UI
|
||||||
|
// thread before the outer function has returned and destroyed
|
||||||
|
// its auto_lock. We need to acquire the lock before deleting
|
||||||
|
// or risk a crash.
|
||||||
|
base::AutoLock auto_lock(subscriber->handler_lock_);
|
||||||
|
}
|
||||||
delete subscriber;
|
delete subscriber;
|
||||||
},
|
},
|
||||||
ptr));
|
ptr));
|
||||||
|
|
Loading…
Reference in a new issue