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

Side by Side Diff: net/quic/quic_http_stream.cc

Issue 1626703002: QUIC - fix crash when writing part of the request body fails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_http_stream.h" 5 #include "net/quic/quic_http_stream.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 raw_request_body_buf_.get(), raw_request_body_buf_->size(), 464 raw_request_body_buf_.get(), raw_request_body_buf_->size(),
465 base::Bind(&QuicHttpStream::OnIOComplete, weak_factory_.GetWeakPtr())); 465 base::Bind(&QuicHttpStream::OnIOComplete, weak_factory_.GetWeakPtr()));
466 } 466 }
467 467
468 int QuicHttpStream::DoReadRequestBodyComplete(int rv) { 468 int QuicHttpStream::DoReadRequestBodyComplete(int rv) {
469 // |rv| is the result of read from the request body from the last call to 469 // |rv| is the result of read from the request body from the last call to
470 // DoSendBody(). 470 // DoSendBody().
471 if (rv < 0) 471 if (rv < 0)
472 return rv; 472 return rv;
473 473
474 // If the stream is already closed, don't continue.
475 if (!stream_)
476 return response_status_;
477
474 request_body_buf_ = new DrainableIOBuffer(raw_request_body_buf_.get(), rv); 478 request_body_buf_ = new DrainableIOBuffer(raw_request_body_buf_.get(), rv);
475 if (rv == 0) { // Reached the end. 479 if (rv == 0) { // Reached the end.
476 DCHECK(request_body_stream_->IsEOF()); 480 DCHECK(request_body_stream_->IsEOF());
477 } 481 }
478 482
479 next_state_ = STATE_SEND_BODY; 483 next_state_ = STATE_SEND_BODY;
480 return OK; 484 return OK;
481 } 485 }
482 486
483 int QuicHttpStream::DoSendBody() { 487 int QuicHttpStream::DoSendBody() {
(...skipping 13 matching lines...) Expand all
497 } 501 }
498 502
499 next_state_ = STATE_OPEN; 503 next_state_ = STATE_OPEN;
500 return OK; 504 return OK;
501 } 505 }
502 506
503 int QuicHttpStream::DoSendBodyComplete(int rv) { 507 int QuicHttpStream::DoSendBodyComplete(int rv) {
504 if (rv < 0) 508 if (rv < 0)
505 return rv; 509 return rv;
506 510
511 // If the stream is already closed, don't continue.
512 if (!stream_)
513 return response_status_;
514
507 request_body_buf_->DidConsume(request_body_buf_->BytesRemaining()); 515 request_body_buf_->DidConsume(request_body_buf_->BytesRemaining());
508 516
509 if (!request_body_stream_->IsEOF()) { 517 if (!request_body_stream_->IsEOF()) {
510 next_state_ = STATE_READ_REQUEST_BODY; 518 next_state_ = STATE_READ_REQUEST_BODY;
511 return OK; 519 return OK;
512 } 520 }
513 521
514 next_state_ = STATE_OPEN; 522 next_state_ = STATE_OPEN;
515 return OK; 523 return OK;
516 } 524 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); 567 closed_stream_sent_bytes_ = stream_->stream_bytes_written();
560 stream_ = nullptr; 568 stream_ = nullptr;
561 569
562 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress 570 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress
563 // read. 571 // read.
564 if (request_body_stream_) 572 if (request_body_stream_)
565 request_body_stream_->Reset(); 573 request_body_stream_->Reset();
566 } 574 }
567 575
568 } // namespace net 576 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698