From 23c348d0f8ffbb7c96e16f5aee6512d7f1e99e86 Mon Sep 17 00:00:00 2001 From: "wtc@chromium.org" Date: Fri, 22 Jun 2012 23:54:43 +0000 Subject: Use begin() to iterate over requests_ (a std::set) while deleting items. R=willchan@chromium.org BUG=131549 TEST=to-do Review URL: https://chromiumcodereview.appspot.com/10640014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143747 0039d316-1c4b-4281-b951-d872f2087c98 --- net/ocsp/nss_ocsp.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'net/ocsp') diff --git a/net/ocsp/nss_ocsp.cc b/net/ocsp/nss_ocsp.cc index 23c00d0..fca6c3d 100644 --- a/net/ocsp/nss_ocsp.cc +++ b/net/ocsp/nss_ocsp.cc @@ -517,12 +517,10 @@ void OCSPIOLoop::RemoveRequest(OCSPRequestSession* request) { } void OCSPIOLoop::CancelAllRequests() { - std::set requests; - requests.swap(requests_); - - for (std::set::iterator it = requests.begin(); - it != requests.end(); ++it) - (*it)->CancelURLRequest(); + // CancelURLRequest() always removes the request from the requests_ + // set synchronously. + while (!requests_.empty()) + (*requests_.begin())->CancelURLRequest(); } OCSPNSSInitialization::OCSPNSSInitialization() { @@ -578,10 +576,11 @@ SECStatus OCSPCreateSession(const char* host, PRUint16 portnum, net::URLRequestContext* request_context = g_request_context; pthread_mutex_unlock(&g_request_context_lock); if (request_context == NULL) { - LOG(ERROR) << "No URLRequestContext for OCSP handler."; - // The application failed to call SetURLRequestContextForOCSP, so we - // can't create and use net::URLRequest. PR_NOT_IMPLEMENTED_ERROR is not an - // accurate error code for this error condition, but is close enough. + LOG(ERROR) << "No URLRequestContext for NSS HTTP handler. host: " << host; + // The application failed to call SetURLRequestContextForNSSHttpIO or + // has already called ShutdownNSSHttpIO, so we can't create and use + // net::URLRequest. PR_NOT_IMPLEMENTED_ERROR is not an accurate error + // code for these error conditions, but is close enough. PORT_SetError(PR_NOT_IMPLEMENTED_ERROR); return SECFailure; } -- cgit v1.1