summaryrefslogtreecommitdiffstats
path: root/net/socket/client_socket_handle.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 06:01:21 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 06:01:21 +0000
commit3ae823083442061c26aa61c72385c3e085fe2fe6 (patch)
tree4cb16dea043374ae181f23b850cc976cfcca1cb3 /net/socket/client_socket_handle.cc
parentea376ac69fd89cf237693834326acca685e7a22d (diff)
downloadchromium_src-3ae823083442061c26aa61c72385c3e085fe2fe6.zip
chromium_src-3ae823083442061c26aa61c72385c3e085fe2fe6.tar.gz
chromium_src-3ae823083442061c26aa61c72385c3e085fe2fe6.tar.bz2
Reset internal ClientSocketHandle state on Init() synchronous error (failure to do so could lead to a crash). Also delete a CHECK that was asserting on possibly deleted memory.
BUG=http://crbug.com/15207 TEST=See bug for repro. Review URL: http://codereview.chromium.org/147155 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19343 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/client_socket_handle.cc')
-rw-r--r--net/socket/client_socket_handle.cc21
1 files changed, 15 insertions, 6 deletions
diff --git a/net/socket/client_socket_handle.cc b/net/socket/client_socket_handle.cc
index 96dec03..15f99a6 100644
--- a/net/socket/client_socket_handle.cc
+++ b/net/socket/client_socket_handle.cc
@@ -16,8 +16,8 @@ ClientSocketHandle::ClientSocketHandle(ClientSocketPool* pool)
: pool_(pool),
socket_(NULL),
is_reused_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- callback_(this, &ClientSocketHandle::OnIOComplete)) {}
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ callback_(this, &ClientSocketHandle::OnIOComplete)) {}
ClientSocketHandle::~ClientSocketHandle() {
Reset();
@@ -29,9 +29,14 @@ int ClientSocketHandle::Init(const std::string& group_name,
CompletionCallback* callback) {
ResetInternal(true);
group_name_ = group_name;
- user_callback_ = callback;
- return pool_->RequestSocket(
+ int rv = pool_->RequestSocket(
group_name, resolve_info, priority, this, &callback_);
+ if (rv == ERR_IO_PENDING) {
+ user_callback_ = callback;
+ } else {
+ HandleInitCompletion(rv);
+ }
+ return rv;
}
void ClientSocketHandle::Reset() {
@@ -62,12 +67,16 @@ LoadState ClientSocketHandle::GetLoadState() const {
}
void ClientSocketHandle::OnIOComplete(int result) {
- CHECK(ERR_IO_PENDING != result);
CompletionCallback* callback = user_callback_;
user_callback_ = NULL;
+ HandleInitCompletion(result);
+ callback->Run(result);
+}
+
+void ClientSocketHandle::HandleInitCompletion(int result) {
+ CHECK(ERR_IO_PENDING != result);
if (result != OK)
ResetInternal(false); // The request failed, so there's nothing to cancel.
- callback->Run(result);
}
} // namespace net