diff options
-rw-r--r-- | net/ocsp/nss_ocsp.cc | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/net/ocsp/nss_ocsp.cc b/net/ocsp/nss_ocsp.cc index e48edc10..3f4daee 100644 --- a/net/ocsp/nss_ocsp.cc +++ b/net/ocsp/nss_ocsp.cc @@ -128,11 +128,7 @@ class OCSPRequestSession void Cancel() { // IO thread may set |io_loop_| to NULL, so protect by |lock_|. AutoLock autolock(lock_); - if (io_loop_) { - io_loop_->PostTask( - FROM_HERE, - NewRunnableMethod(this, &OCSPRequestSession::CancelURLRequest)); - } + CancelLocked(); } bool Finished() const { @@ -152,7 +148,7 @@ class OCSPRequestSession if (timeout < base::TimeDelta()) { LOG(INFO) << "OCSP Timed out"; if (!finished_) - Cancel(); + CancelLocked(); break; } } @@ -225,6 +221,7 @@ class OCSPRequestSession io_loop_ = NULL; } cv_.Signal(); + Release(); // Balanced with StartURLRequest(). } } @@ -234,11 +231,7 @@ class OCSPRequestSession AutoLock autolock(lock_); io_loop_ = NULL; } - if (request_) { - request_->Cancel(); - delete request_; - request_ = NULL; - } + CancelURLRequest(); } private: @@ -250,6 +243,14 @@ class OCSPRequestSession io_loop_->RemoveDestructionObserver(this); } + void CancelLocked() { + if (io_loop_) { + io_loop_->PostTask( + FROM_HERE, + NewRunnableMethod(this, &OCSPRequestSession::CancelURLRequest)); + } + } + void StartURLRequest() { DCHECK_EQ(MessageLoopForIO::current(), io_loop_); DCHECK(!request_); @@ -279,6 +280,7 @@ class OCSPRequestSession request_->SetExtraRequestHeaders(extra_request_headers_); request_->Start(); + AddRef(); // Release after |request_| deleted. } void CancelURLRequest() { @@ -288,6 +290,13 @@ class OCSPRequestSession request_->Cancel(); delete request_; request_ = NULL; + { + AutoLock autolock(lock_); + finished_ = true; + io_loop_ = NULL; + } + cv_.Signal(); + Release(); // Balanced with StartURLRequest(). } } |