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

Unified Diff: net/spdy/spdy_http_stream.cc

Issue 2022053002: Introduce error handling in SpdyHttpStream on UploadDataStream::Read() failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
Index: net/spdy/spdy_http_stream.cc
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc
index 259581a5229173cc2e7fcbc84963396f357c0d80..465dfd5a2dd93fa64b13564de5762b13b85969ce 100644
--- a/net/spdy/spdy_http_stream.cc
+++ b/net/spdy/spdy_http_stream.cc
@@ -302,8 +302,13 @@ void SpdyHttpStream::Cancel() {
}
void SpdyHttpStream::OnRequestHeadersSent() {
- if (!request_callback_.is_null())
+ if (!request_callback_.is_null()) {
+ // Avoid reseting the callback as long as it is used on errors in
+ // OnRequestBodyReadCompleted() method.
mmenke 2016/06/01 17:24:07 We should not be invoking the callback twice, unde
maksims (do not use this acc) 2016/06/03 11:39:08 Done.
+ const CompletionCallback cb = request_callback_;
DoRequestCallback(OK);
+ request_callback_ = cb;
+ }
// TODO(akalin): Do this immediately after sending the request
// headers.
@@ -448,13 +453,28 @@ void SpdyHttpStream::ReadAndSendRequestBodyData() {
weak_factory_.GetWeakPtr()));
if (rv != ERR_IO_PENDING) {
- // ERR_IO_PENDING is the only possible error.
- CHECK_GE(rv, 0);
+ // UploadDataStream::Read() can fail reading data
OnRequestBodyReadCompleted(rv);
}
}
+void SpdyHttpStream::ResetStreamInternal() {
+ spdy_session_->ResetStream(stream()->stream_id(), RST_STREAM_INTERNAL_ERROR,
+ std::string());
+}
+
void SpdyHttpStream::OnRequestBodyReadCompleted(int status) {
+ if (status < 0) {
+ DCHECK_NE(ERR_IO_PENDING, status);
+ if (!request_callback_.is_null()) {
+ DoRequestCallback(status);
+ }
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&SpdyHttpStream::ResetStreamInternal,
+ weak_factory_.GetWeakPtr()));
mmenke 2016/06/01 17:24:07 Should do this first - invoking |request_callback_
maksims (do not use this acc) 2016/06/02 12:43:12 Do you mean - base::WeakPtr<SpdyHttpStream> weak_p
mmenke 2016/06/02 15:02:10 No, I mean do the PostTask to reset the stream, an
maksims (do not use this acc) 2016/06/03 11:39:08 Done.
+ return;
+ }
+
CHECK_GE(status, 0);
request_body_buf_size_ = status;
const bool eof = request_info_->upload_data_stream->IsEOF();

Powered by Google App Engine
This is Rietveld 408576698