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

Unified Diff: net/socket/client_socket_handle.cc

Issue 2994003: Refactor how ClientSocketPoolBaseHelper avoids re-entrancy. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Merge. Created 10 years, 5 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/socket/client_socket_handle.h ('k') | net/socket/client_socket_pool.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/client_socket_handle.cc
diff --git a/net/socket/client_socket_handle.cc b/net/socket/client_socket_handle.cc
index 73142bfcb9502b27b8a9d9240b5d2ca371d599d1..7093e14732e6271a1c69047fc22523b32830073d 100644
--- a/net/socket/client_socket_handle.cc
+++ b/net/socket/client_socket_handle.cc
@@ -14,7 +14,7 @@
namespace net {
ClientSocketHandle::ClientSocketHandle()
- : socket_(NULL),
+ : is_initialized_(false),
is_reused_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(
callback_(this, &ClientSocketHandle::OnIOComplete)),
@@ -32,7 +32,7 @@ void ClientSocketHandle::Reset() {
void ClientSocketHandle::ResetInternal(bool cancel) {
if (group_name_.empty()) // Was Init called?
return;
- if (socket_.get()) {
+ if (is_initialized()) {
// Because of http://crbug.com/37810 we may not have a pool, but have
// just a raw socket.
socket_->NetLog().EndEvent(NetLog::TYPE_SOCKET_IN_USE, NULL);
@@ -41,10 +41,11 @@ void ClientSocketHandle::ResetInternal(bool cancel) {
// it can be deleted or reused.
pool_->ReleaseSocket(group_name_, release_socket(), pool_id_);
} else if (cancel) {
- // If we did not get initialized yet, so we've got a socket request pending.
+ // If we did not get initialized yet, we've got a socket request pending.
// Cancel it.
pool_->CancelRequest(group_name_, this);
}
+ is_initialized_ = false;
group_name_.clear();
is_reused_ = false;
user_callback_ = NULL;
@@ -82,8 +83,11 @@ void ClientSocketHandle::HandleInitCompletion(int result) {
if (result != OK) {
if (!socket_.get())
ResetInternal(false); // Nothing to cancel since the request failed.
+ else
+ is_initialized_ = true;
return;
}
+ is_initialized_ = true;
CHECK_NE(-1, pool_id_) << "Pool should have set |pool_id_| to a valid value.";
setup_time_ = base::TimeTicks::Now() - init_time_;
« no previous file with comments | « net/socket/client_socket_handle.h ('k') | net/socket/client_socket_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698