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

Side by Side Diff: net/spdy/spdy_session_spdy2_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 | « no previous file | net/spdy/spdy_session_spdy3_unittest.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 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 EXPECT_EQ(3u, spdy_stream1->stream_id()); 1273 EXPECT_EQ(3u, spdy_stream1->stream_id());
1274 EXPECT_EQ(1u, spdy_stream2->stream_id()); 1274 EXPECT_EQ(1u, spdy_stream2->stream_id());
1275 1275
1276 spdy_stream1->Cancel(); 1276 spdy_stream1->Cancel();
1277 spdy_stream1 = NULL; 1277 spdy_stream1 = NULL;
1278 1278
1279 spdy_stream2->Cancel(); 1279 spdy_stream2->Cancel();
1280 spdy_stream2 = NULL; 1280 spdy_stream2 = NULL;
1281 } 1281 }
1282 1282
1283 TEST_F(SpdySessionSpdy2Test, CancelStream) {
1284 MockConnect connect_data(SYNCHRONOUS, OK);
1285 // Request 1, at HIGHEST priority, will be cancelled before it writes data.
1286 // Request 2, at LOWEST priority, will be a full request and will be id 1.
1287 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
1288 MockWrite writes[] = {
1289 CreateMockWrite(*req2, 0),
1290 };
1291
1292 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 1));
1293 scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(1, true));
1294 MockRead reads[] = {
1295 CreateMockRead(*resp2, 1),
1296 CreateMockRead(*body2, 2),
1297 MockRead(ASYNC, 0, 3) // EOF
1298 };
1299
1300 SpdySessionDependencies session_deps;
1301 session_deps.host_resolver->set_synchronous_mode(true);
1302
1303 DeterministicSocketData data(reads, arraysize(reads),
1304 writes, arraysize(writes));
1305 data.set_connect_data(connect_data);
1306 session_deps.deterministic_socket_factory->AddSocketDataProvider(&data);
1307
1308 SSLSocketDataProvider ssl(SYNCHRONOUS, OK);
1309 session_deps.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl);
1310
1311 scoped_refptr<HttpNetworkSession> http_session(
1312 SpdySessionDependencies::SpdyCreateSessionDeterministic(&session_deps));
1313
1314 const std::string kTestHost("www.foo.com");
1315 const int kTestPort = 80;
1316 HostPortPair test_host_port_pair(kTestHost, kTestPort);
1317 HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct());
1318
1319 SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool());
1320
1321 // Create a session.
1322 EXPECT_FALSE(spdy_session_pool->HasSession(pair));
1323 scoped_refptr<SpdySession> session =
1324 spdy_session_pool->Get(pair, BoundNetLog());
1325 ASSERT_TRUE(spdy_session_pool->HasSession(pair));
1326
1327 scoped_refptr<TransportSocketParams> transport_params(
1328 new TransportSocketParams(test_host_port_pair,
1329 MEDIUM,
1330 false,
1331 false,
1332 OnHostResolutionCallback()));
1333 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
1334 EXPECT_EQ(OK, connection->Init(test_host_port_pair.ToString(),
1335 transport_params, MEDIUM, CompletionCallback(),
1336 http_session->GetTransportSocketPool(
1337 HttpNetworkSession::NORMAL_SOCKET_POOL),
1338 BoundNetLog()));
1339 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
1340
1341 scoped_refptr<SpdyStream> spdy_stream1;
1342 TestCompletionCallback callback1;
1343 GURL url1("http://www.google.com");
1344 EXPECT_EQ(OK, session->CreateStream(url1, HIGHEST, &spdy_stream1,
1345 BoundNetLog(), callback1.callback()));
1346 EXPECT_EQ(0u, spdy_stream1->stream_id());
1347
1348 scoped_refptr<SpdyStream> spdy_stream2;
1349 TestCompletionCallback callback2;
1350 GURL url2("http://www.google.com");
1351 EXPECT_EQ(OK, session->CreateStream(url2, LOWEST, &spdy_stream2,
1352 BoundNetLog(), callback2.callback()));
1353 EXPECT_EQ(0u, spdy_stream2->stream_id());
1354
1355 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
1356 (*headers)["method"] = "GET";
1357 (*headers)["scheme"] = url1.scheme();
1358 (*headers)["host"] = url1.host();
1359 (*headers)["url"] = url1.path();
1360 (*headers)["version"] = "HTTP/1.1";
1361 scoped_ptr<SpdyHeaderBlock> headers2(new SpdyHeaderBlock);
1362 *headers2 = *headers;
1363
1364 spdy_stream1->set_spdy_headers(headers.Pass());
1365 EXPECT_TRUE(spdy_stream1->HasUrl());
1366
1367 spdy_stream2->set_spdy_headers(headers2.Pass());
1368 EXPECT_TRUE(spdy_stream2->HasUrl());
1369
1370 spdy_stream1->SendRequest(false);
1371 spdy_stream2->SendRequest(false);
1372
1373 EXPECT_EQ(0u, spdy_stream1->stream_id());
1374
1375 spdy_stream1->Cancel();
1376
1377 EXPECT_EQ(0u, spdy_stream1->stream_id());
1378
1379 data.RunFor(1);
1380
1381 EXPECT_EQ(0u, spdy_stream1->stream_id());
1382 EXPECT_EQ(1u, spdy_stream2->stream_id());
1383
1384 spdy_stream1 = NULL;
1385 spdy_stream2->Cancel();
1386 spdy_stream2 = NULL;
1387 }
1388
1283 } // namespace net 1389 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/spdy/spdy_session_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698