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

Side by Side Diff: net/spdy/spdy_session_spdy3_unittest.cc

Issue 10829066: Fix a SPDY crash bug where a CHECK() is hit because a cancelled stream is considered active by the … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: only call CloseCreatedStream when stream_id == 0 Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_session_spdy2_unittest.cc ('k') | net/spdy/spdy_stream.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/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include "net/base/host_cache.h" 7 #include "net/base/host_cache.h"
8 #include "net/base/ip_endpoint.h" 8 #include "net/base/ip_endpoint.h"
9 #include "net/base/net_log_unittest.h" 9 #include "net/base/net_log_unittest.h"
10 #include "net/spdy/spdy_io_buffer.h" 10 #include "net/spdy/spdy_io_buffer.h"
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 EXPECT_EQ(3u, spdy_stream1->stream_id()); 1443 EXPECT_EQ(3u, spdy_stream1->stream_id());
1444 EXPECT_EQ(1u, spdy_stream2->stream_id()); 1444 EXPECT_EQ(1u, spdy_stream2->stream_id());
1445 1445
1446 spdy_stream1->Cancel(); 1446 spdy_stream1->Cancel();
1447 spdy_stream1 = NULL; 1447 spdy_stream1 = NULL;
1448 1448
1449 spdy_stream2->Cancel(); 1449 spdy_stream2->Cancel();
1450 spdy_stream2 = NULL; 1450 spdy_stream2 = NULL;
1451 } 1451 }
1452 1452
1453 TEST_F(SpdySessionSpdy3Test, CancelStream) {
1454 MockConnect connect_data(SYNCHRONOUS, OK);
1455 // Request 1, at HIGHEST priority, will be cancelled before it writes data.
1456 // Request 2, at LOWEST priority, will be a full request and will be id 1.
1457 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
1458 MockWrite writes[] = {
1459 CreateMockWrite(*req2, 0),
1460 };
1461
1462 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 1));
1463 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(1, true));
1464 MockRead reads[] = {
1465 CreateMockRead(*resp2, 1),
1466 CreateMockRead(*body2, 2),
1467 MockRead(ASYNC, 0, 3) // EOF
1468 };
1469
1470 SpdySessionDependencies session_deps;
1471 session_deps.host_resolver->set_synchronous_mode(true);
1472
1473 DeterministicSocketData data(reads, arraysize(reads),
1474 writes, arraysize(writes));
1475 data.set_connect_data(connect_data);
1476 session_deps.deterministic_socket_factory->AddSocketDataProvider(&data);
1477
1478 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
1479 session_deps.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl);
1480
1481 scoped_refptr<HttpNetworkSession> http_session(
1482 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps));
1483
1484 const std::string kTestHost("www.foo.com");
1485 const int kTestPort = 80;
1486 HostPortPair test_host_port_pair(kTestHost, kTestPort);
1487 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct());
1488
1489 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool());
1490
1491 // Create a session.
1492 EXPECT_FALSE(spdy_session_pool->HasSession(pair));
1493 scoped_refptr<SpdySession> session =
1494 spdy_session_pool->Get(pair, BoundNetLog());
1495 ASSERT_TRUE(spdy_session_pool->HasSession(pair));
1496
1497 scoped_refptr<TransportSocketParams> transport_params(
1498 new TransportSocketParams(test_host_port_pair,
1499 MEDIUM,
1500 false,
1501 false,
1502 OnHostResolutionCallback()));
1503 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
1504 EXPECT_EQ(OK, connection->Init(test_host_port_pair.ToString(),
1505 transport_params, MEDIUM, CompletionCallback(),
1506 http_session->GetTransportSocketPool(
1507 HttpNetworkSession::NORMAL_SOCKET_POOL),
1508 BoundNetLog()));
1509 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
1510
1511 scoped_refptr<SpdyStream> spdy_stream1;
1512 TestCompletionCallback callback1;
1513 GURL url1("http://www.google.com");
1514 EXPECT_EQ(OK, session->CreateStream(url1, HIGHEST, &spdy_stream1,
1515 BoundNetLog(), callback1.callback()));
1516 EXPECT_EQ(0u, spdy_stream1->stream_id());
1517
1518 scoped_refptr<SpdyStream> spdy_stream2;
1519 TestCompletionCallback callback2;
1520 GURL url2("http://www.google.com");
1521 EXPECT_EQ(OK, session->CreateStream(url2, LOWEST, &spdy_stream2,
1522 BoundNetLog(), callback2.callback()));
1523 EXPECT_EQ(0u, spdy_stream2->stream_id());
1524
1525 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
1526 (*headers)[":method"] = "GET";
1527 (*headers)[":scheme"] = url1.scheme();
1528 (*headers)[":host"] = url1.host();
1529 (*headers)[":path"] = url1.path();
1530 (*headers)[":version"] = "HTTP/1.1";
1531 scoped_ptr<SpdyHeaderBlock> headers2(new SpdyHeaderBlock);
1532 *headers2 = *headers;
1533
1534 spdy_stream1->set_spdy_headers(headers.Pass());
1535 EXPECT_TRUE(spdy_stream1->HasUrl());
1536
1537 spdy_stream2->set_spdy_headers(headers2.Pass());
1538 EXPECT_TRUE(spdy_stream2->HasUrl());
1539
1540 spdy_stream1->SendRequest(false);
1541 spdy_stream2->SendRequest(false);
1542
1543 EXPECT_EQ(0u, spdy_stream1->stream_id());
1544
1545 spdy_stream1->Cancel();
1546
1547 EXPECT_EQ(0u, spdy_stream1->stream_id());
1548
1549 data.RunFor(1);
1550
1551 EXPECT_EQ(0u, spdy_stream1->stream_id());
1552 EXPECT_EQ(1u, spdy_stream2->stream_id());
1553
1554 spdy_stream1 = NULL;
1555 spdy_stream2->Cancel();
1556 spdy_stream2 = NULL;
1557 }
1558
1453 } // namespace net 1559 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session_spdy2_unittest.cc ('k') | net/spdy/spdy_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698