summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-19 22:00:28 +0000
committermbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-19 22:00:28 +0000
commit57f123221a8e8826262cb0037875372b6c76338d (patch)
tree3ad043fa198d6de6c6bb13286f6fe5d3650530d2
parent8dc5a205c581c3adf5aeebf6d4ccb4a9c8176658 (diff)
downloadchromium_src-57f123221a8e8826262cb0037875372b6c76338d.zip
chromium_src-57f123221a8e8826262cb0037875372b6c76338d.tar.gz
chromium_src-57f123221a8e8826262cb0037875372b6c76338d.tar.bz2
Currently the code will recursively call between
ReadSocket() OnReadComplete() ReadSocket() ... as long as the reads are completing synchronously. This is not a huge problem, but avoiding recursion offsers some robustness and avoids stack blowouts. BUG=none TEST=none Review URL: http://codereview.chromium.org/546071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36553 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/flip/flip_session.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/net/flip/flip_session.cc b/net/flip/flip_session.cc
index 1f33c69..b5226b3 100644
--- a/net/flip/flip_session.cc
+++ b/net/flip/flip_session.cc
@@ -547,9 +547,7 @@ void FlipSession::OnReadComplete(int bytes_read) {
if (flip_framer_.state() == flip::FlipFramer::FLIP_DONE)
flip_framer_.Reset();
}
- // NOTE(mbelshe): Could cause circular callbacks. (when ReadSocket
- // completes synchronously, calling OnReadComplete, etc). Should
- // probably return to the message loop.
+
ReadSocket();
}
@@ -624,8 +622,11 @@ void FlipSession::ReadSocket() {
return;
default:
// Data was read, process it.
- // TODO(mbelshe): check that we can't get a recursive stack?
- OnReadComplete(bytes_read);
+ // Schedule the work through the message loop to avoid recursive
+ // callbacks.
+ read_pending_ = true;
+ MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
+ this, &FlipSession::OnReadComplete, bytes_read));
break;
}
}