OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/cert_verifier.h" | 5 #include "net/base/cert_verifier.h" |
6 | 6 |
| 7 #if defined(OS_LINUX) |
| 8 #include <private/pprthred.h> // PR_DetatchThread |
| 9 #endif |
| 10 |
7 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
8 #include "base/worker_pool.h" | 12 #include "base/worker_pool.h" |
9 #include "net/base/cert_verify_result.h" | 13 #include "net/base/cert_verify_result.h" |
10 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
11 #include "net/base/x509_certificate.h" | 15 #include "net/base/x509_certificate.h" |
12 | 16 |
13 namespace net { | 17 namespace net { |
14 | 18 |
15 class CertVerifier::Request : | 19 class CertVerifier::Request : |
16 public base::RefCountedThreadSafe<CertVerifier::Request> { | 20 public base::RefCountedThreadSafe<CertVerifier::Request> { |
(...skipping 12 matching lines...) Expand all Loading... |
29 callback_(callback), | 33 callback_(callback), |
30 origin_loop_(MessageLoop::current()), | 34 origin_loop_(MessageLoop::current()), |
31 error_(OK) { | 35 error_(OK) { |
32 } | 36 } |
33 | 37 |
34 ~Request() {} | 38 ~Request() {} |
35 | 39 |
36 void DoVerify() { | 40 void DoVerify() { |
37 // Running on the worker thread | 41 // Running on the worker thread |
38 error_ = cert_->Verify(hostname_, rev_checking_enabled_, &result_); | 42 error_ = cert_->Verify(hostname_, rev_checking_enabled_, &result_); |
| 43 #if defined(OS_LINUX) |
| 44 // Detach the thread from NSPR. |
| 45 // Calling NSS functions attaches the thread to NSPR, which stores |
| 46 // the NSPR thread ID in thread-specific data. |
| 47 // The threads in our thread pool terminate after we have called |
| 48 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets |
| 49 // segfaults on shutdown when the threads' thread-specific data |
| 50 // destructors run. |
| 51 PR_DetachThread(); |
| 52 #endif |
39 | 53 |
40 Task* reply = NewRunnableMethod(this, &Request::DoCallback); | 54 Task* reply = NewRunnableMethod(this, &Request::DoCallback); |
41 | 55 |
42 // The origin loop could go away while we are trying to post to it, so we | 56 // The origin loop could go away while we are trying to post to it, so we |
43 // need to call its PostTask method inside a lock. See ~CertVerifier. | 57 // need to call its PostTask method inside a lock. See ~CertVerifier. |
44 { | 58 { |
45 AutoLock locked(origin_loop_lock_); | 59 AutoLock locked(origin_loop_lock_); |
46 if (origin_loop_) { | 60 if (origin_loop_) { |
47 origin_loop_->PostTask(FROM_HERE, reply); | 61 origin_loop_->PostTask(FROM_HERE, reply); |
48 reply = NULL; | 62 reply = NULL; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 NewRunnableMethod(request_.get(), &Request::DoVerify), true)) { | 144 NewRunnableMethod(request_.get(), &Request::DoVerify), true)) { |
131 NOTREACHED(); | 145 NOTREACHED(); |
132 request_ = NULL; | 146 request_ = NULL; |
133 return ERR_FAILED; | 147 return ERR_FAILED; |
134 } | 148 } |
135 | 149 |
136 return ERR_IO_PENDING; | 150 return ERR_IO_PENDING; |
137 } | 151 } |
138 | 152 |
139 } // namespace net | 153 } // namespace net |
OLD | NEW |