diff options
author | Valentin Gosu <valentin.gosu@gmail.com> | 2019-12-06 13:01:55 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-12-06 13:01:55 +0100 |
commit | d8282a0da137a1e503b1c89febdbe766a55b750a (patch) | |
tree | cb9dd3a1d164263ea09d6029d64f16515915876c /netwerk | |
parent | 74f15fb2d6c0e6de7b15631aada9997d000bd8ac (diff) | |
download | UXP-d8282a0da137a1e503b1c89febdbe766a55b750a.tar UXP-d8282a0da137a1e503b1c89febdbe766a55b750a.tar.gz UXP-d8282a0da137a1e503b1c89febdbe766a55b750a.tar.lz UXP-d8282a0da137a1e503b1c89febdbe766a55b750a.tar.xz UXP-d8282a0da137a1e503b1c89febdbe766a55b750a.zip |
Use mutex in PACResolver when accessing mRequest from multiple threads.
Diffstat (limited to 'netwerk')
-rw-r--r-- | netwerk/base/ProxyAutoConfig.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/netwerk/base/ProxyAutoConfig.cpp b/netwerk/base/ProxyAutoConfig.cpp index 4d7a6c1fd..6a9577669 100644 --- a/netwerk/base/ProxyAutoConfig.cpp +++ b/netwerk/base/ProxyAutoConfig.cpp @@ -271,6 +271,7 @@ public: PACResolver() : mStatus(NS_ERROR_FAILURE) + , mMutex("PACResolver::Mutex") { } @@ -279,9 +280,15 @@ public: nsIDNSRecord *record, nsresult status) override { - if (mTimer) { - mTimer->Cancel(); - mTimer = nullptr; + nsCOMPtr<nsITimer> timer; + { + MutexAutoLock lock(mMutex); + timer.swap(mTimer); + mRequest = nullptr; + } + + if (timer) { + timer->Cancel(); } mRequest = nullptr; @@ -293,9 +300,15 @@ public: // nsITimerCallback NS_IMETHOD Notify(nsITimer *timer) override { - if (mRequest) - mRequest->Cancel(NS_ERROR_NET_TIMEOUT); - mTimer = nullptr; + nsCOMPtr<nsICancelable> request; + { + MutexAutoLock lock(mMutex); + request.swap(mRequest); + mTimer = nullptr; + } + if (request) { + request->Cancel(NS_ERROR_NET_TIMEOUT); + } return NS_OK; } @@ -303,6 +316,7 @@ public: nsCOMPtr<nsICancelable> mRequest; nsCOMPtr<nsIDNSRecord> mResponse; nsCOMPtr<nsITimer> mTimer; + Mutex mMutex; private: ~PACResolver() {} |