Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Unified Diff: net/ocsp/nss_ocsp.cc

Issue 165362: Try to fix crash in OCSP handlers. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/x509_certificate_nss.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ocsp/nss_ocsp.cc
===================================================================
--- net/ocsp/nss_ocsp.cc (revision 23680)
+++ net/ocsp/nss_ocsp.cc (working copy)
@@ -80,7 +80,7 @@
OCSPRequestSession(const GURL& url,
const char* http_request_method,
base::TimeDelta timeout);
- ~OCSPRequestSession() {}
+ ~OCSPRequestSession();
void SetPostData(const char* http_data,
const PRUint32 http_data_len,
@@ -137,15 +137,18 @@
public URLRequest::Delegate {
public:
explicit Core(OCSPRequestSession* req)
- : ocsp_req_(req),
- url_(ocsp_req_->url()),
+ : url_(req->url()),
+ http_request_method_(req->http_request_method()),
+ timeout_(req->timeout()),
io_loop_(Singleton<OCSPInitSingleton>::get()->io_thread()),
request_(NULL),
buffer_(new net::IOBuffer(kRecvBufferSize)),
response_code_(-1),
cv_(&lock_),
finished_(false) {}
- virtual ~Core() {}
+ virtual ~Core() {
+ DCHECK(!request_);
+ }
void SetPostData(const char* http_data, PRUint32 http_data_len,
const char* http_content_type) {
@@ -181,7 +184,7 @@
}
bool Wait() {
- base::TimeDelta timeout = ocsp_req_->timeout();
+ base::TimeDelta timeout = timeout_;
AutoLock autolock(lock_);
while (!finished_) {
base::TimeTicks last_time = base::TimeTicks::Now();
@@ -226,6 +229,7 @@
virtual void OnResponseStarted(URLRequest* request) {
DCHECK(request == request_);
DCHECK(MessageLoopForIO::current() == io_loop_);
+
int bytes_read = 0;
if (request->status().is_success()) {
response_code_ = request_->GetResponseCode();
@@ -269,7 +273,7 @@
request_->set_load_flags(
net::LOAD_DISABLE_CACHE|net::LOAD_DO_NOT_SAVE_COOKIES);
- if (ocsp_req_->http_request_method() == "POST") {
+ if (http_request_method_ == "POST") {
DCHECK(!upload_content_.empty());
DCHECK(!upload_content_type_.empty());
@@ -290,13 +294,15 @@
void CancelURLRequest() {
DCHECK(MessageLoopForIO::current() == io_loop_);
if (request_) {
+ request_->Cancel();
delete request_;
request_ = NULL;
}
}
- OCSPRequestSession* ocsp_req_; // corresponding OCSP session
GURL url_; // The URL we eventually wound up at
+ std::string http_request_method_;
+ base::TimeDelta timeout_; // The timeout for OCSP
MessageLoop* io_loop_; // Message loop of the IO thread
URLRequest* request_; // The actual request this wraps
scoped_refptr<net::IOBuffer> buffer_; // Read buffer
@@ -326,6 +332,10 @@
ALLOW_THIS_IN_INITIALIZER_LIST(core_(new Core(this))) {
}
+OCSPRequestSession::~OCSPRequestSession() {
+ core_->Cancel();
+}
+
void OCSPRequestSession::SetPostData(const char* http_data,
const PRUint32 http_data_len,
const char* http_content_type) {
@@ -508,7 +518,7 @@
return false;
}
}
- LOG(INFO) << "OSCP response "
+ LOG(INFO) << "OCSP response "
<< " response_code=" << req->http_response_code()
<< " content_type=" << req->http_response_content_type()
<< " header=" << req->http_response_headers()
« no previous file with comments | « net/base/x509_certificate_nss.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698