| Index: net/spdy/spdy_session.cc
|
| ===================================================================
|
| --- net/spdy/spdy_session.cc (revision 181407)
|
| +++ net/spdy/spdy_session.cc (working copy)
|
| @@ -233,6 +233,7 @@
|
| http_server_properties_(http_server_properties),
|
| connection_(new ClientSocketHandle),
|
| read_buffer_(new IOBuffer(kReadBufferSize)),
|
| + read_pending_(false),
|
| stream_hi_water_mark_(kFirstStreamId),
|
| write_pending_(false),
|
| delayed_write_pending_(false),
|
| @@ -781,17 +782,22 @@
|
|
|
| void SpdySession::OnReadComplete(int bytes_read) {
|
| DCHECK_NE(state_, STATE_DO_READ);
|
| + read_pending_ = false;
|
| DoLoop(bytes_read);
|
| }
|
|
|
| void SpdySession::StartRead() {
|
| DCHECK_NE(state_, STATE_DO_READ_COMPLETE);
|
| + read_pending_ = false;
|
| DoLoop(OK);
|
| }
|
|
|
| int SpdySession::DoLoop(int result) {
|
| bytes_read_ = 0;
|
| do {
|
| + if (read_pending_)
|
| + return OK;
|
| +
|
| switch (state_) {
|
| case STATE_DO_READ:
|
| DCHECK_EQ(result, OK);
|
| @@ -813,6 +819,7 @@
|
| }
|
|
|
| int SpdySession::DoRead() {
|
| + DCHECK(!read_pending_);
|
| if (bytes_read_ > kMaxReadBytes) {
|
| state_ = STATE_DO_READ;
|
| MessageLoop::current()->PostTask(
|
| @@ -825,10 +832,13 @@
|
| CHECK(connection_.get());
|
| CHECK(connection_->socket());
|
| state_ = STATE_DO_READ_COMPLETE;
|
| - return connection_->socket()->Read(
|
| + int result = connection_->socket()->Read(
|
| read_buffer_.get(),
|
| kReadBufferSize,
|
| base::Bind(&SpdySession::OnReadComplete, base::Unretained(this)));
|
| + if (result == net::ERR_IO_PENDING)
|
| + read_pending_ = true;
|
| + return result;
|
| }
|
|
|
| int SpdySession::DoReadComplete(int result) {
|
| @@ -836,6 +846,8 @@
|
| // buffer (32KB).
|
| // TODO(mbelshe): support arbitrarily large frames!
|
|
|
| + DCHECK(!read_pending_);
|
| +
|
| if (result <= 0) {
|
| // Session is tearing down.
|
| net::Error error = static_cast<net::Error>(result);
|
|
|