diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 20:13:38 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 20:13:38 +0000 |
commit | 3908c02172554f742c2f70c12e75915e4fb23e3d (patch) | |
tree | 8605609d836042aa3f6dc2e98e09aa36ca672604 /net/proxy | |
parent | 270b9088890d22620d7f8791687fa3ddabe5d1a6 (diff) | |
download | chromium_src-3908c02172554f742c2f70c12e75915e4fb23e3d.zip chromium_src-3908c02172554f742c2f70c12e75915e4fb23e3d.tar.gz chromium_src-3908c02172554f742c2f70c12e75915e4fb23e3d.tar.bz2 |
Try to fix a deadlock that happened when running the network diagnostic tool tests,
by releasing the V8 lock while executing the JS bindings functions.
I don't fully understand how the deadlock happens, but this is a desirable change anyway as it increases the parallelism when running concurrent proxy resolvers.
BUG=44013,44005
Review URL: http://codereview.chromium.org/2023009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47181 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy')
-rw-r--r-- | net/proxy/proxy_resolver_v8.cc | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc index 3366a56..3b04b91 100644 --- a/net/proxy/proxy_resolver_v8.cc +++ b/net/proxy/proxy_resolver_v8.cc @@ -293,15 +293,21 @@ class ProxyResolverV8::Context { Context* context = static_cast<Context*>(v8::External::Cast(*args.Data())->Value()); - context->current_request_net_log_.BeginEvent( - NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS, NULL); + std::string result; - // We shouldn't be called with any arguments, but will not complain if - // we are. - std::string result = context->js_bindings_->MyIpAddress(); + { + v8::Unlocker unlocker; - context->current_request_net_log_.EndEvent( - NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS, NULL); + context->current_request_net_log_.BeginEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS, NULL); + + // We shouldn't be called with any arguments, but will not complain if + // we are. + result = context->js_bindings_->MyIpAddress(); + + context->current_request_net_log_.EndEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS, NULL); + } if (result.empty()) result = "127.0.0.1"; @@ -314,15 +320,21 @@ class ProxyResolverV8::Context { Context* context = static_cast<Context*>(v8::External::Cast(*args.Data())->Value()); - context->current_request_net_log_.BeginEvent( - NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS_EX, NULL); + std::string result; - // We shouldn't be called with any arguments, but will not complain if - // we are. - std::string result = context->js_bindings_->MyIpAddressEx(); + { + v8::Unlocker unlocker; - context->current_request_net_log_.EndEvent( - NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS_EX, NULL); + context->current_request_net_log_.BeginEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS_EX, NULL); + + // We shouldn't be called with any arguments, but will not complain if + // we are. + context->js_bindings_->MyIpAddressEx(); + + context->current_request_net_log_.EndEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS_EX, NULL); + } return StdStringToV8String(result); } @@ -337,13 +349,19 @@ class ProxyResolverV8::Context { return v8::Null(); std::string host = V8StringToStdString(args[0]->ToString()); - context->current_request_net_log_.BeginEvent( - NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE, NULL); + std::string result; - std::string result = context->js_bindings_->DnsResolve(host); + { + v8::Unlocker unlocker; - context->current_request_net_log_.EndEvent( - NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE, NULL); + context->current_request_net_log_.BeginEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE, NULL); + + result = context->js_bindings_->DnsResolve(host); + + context->current_request_net_log_.EndEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE, NULL); + } // DnsResolve() returns empty string on failure. return result.empty() ? v8::Null() : StdStringToV8String(result); @@ -359,13 +377,19 @@ class ProxyResolverV8::Context { return v8::Undefined(); std::string host = V8StringToStdString(args[0]->ToString()); - context->current_request_net_log_.BeginEvent( - NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE_EX, NULL); + std::string result; - std::string result = context->js_bindings_->DnsResolveEx(host); + { + v8::Unlocker unlocker; - context->current_request_net_log_.EndEvent( - NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE_EX, NULL); + context->current_request_net_log_.BeginEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE_EX, NULL); + + result = context->js_bindings_->DnsResolveEx(host); + + context->current_request_net_log_.EndEvent( + NetLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE_EX, NULL); + } return StdStringToV8String(result); } |