Skip to content

Commit

Permalink
bug 855185 - test for thread safety of resetIPFamily() r=honzab
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmanus committed May 1, 2013
1 parent 5fd7b26 commit b75c3e8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions netwerk/protocol/http/nsHttpConnectionMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ nsHttpConnectionMgr::LookupConnectionEntry(nsHttpConnectionInfo *ci,
nsHttpConnection *conn,
nsHttpTransaction *trans)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
if (!ci)
return nullptr;

Expand Down Expand Up @@ -574,6 +575,8 @@ void
nsHttpConnectionMgr::ReportSpdyCWNDSetting(nsHttpConnectionInfo *ci,
uint32_t cwndValue)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);

if (!gHttpHandler->UseSpdyPersistentSettings())
return;

Expand All @@ -600,6 +603,8 @@ nsHttpConnectionMgr::ReportSpdyCWNDSetting(nsHttpConnectionInfo *ci,
uint32_t
nsHttpConnectionMgr::GetSpdyCWNDSetting(nsHttpConnectionInfo *ci)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);

if (!gHttpHandler->UseSpdyPersistentSettings())
return 0;

Expand Down Expand Up @@ -886,6 +891,7 @@ nsHttpConnectionMgr::PruneDeadConnectionsCB(const nsACString &key,
nsAutoPtr<nsConnectionEntry> &ent,
void *closure)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
nsHttpConnectionMgr *self = (nsHttpConnectionMgr *) closure;

LOG((" pruning [ci=%s]\n", ent->mConnInfo->HashKey().get()));
Expand Down Expand Up @@ -2222,6 +2228,7 @@ void
nsHttpConnectionMgr::OnMsgClosePersistentConnections(int32_t, void *)
{
LOG(("nsHttpConnectionMgr::OnMsgClosePersistentConnections\n"));
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);

mCT.Enumerate(ClosePersistentConnectionsCB, this);
}
Expand Down Expand Up @@ -3387,6 +3394,7 @@ nsHttpConnectionMgr::GetConnectionData(nsTArray<mozilla::net::HttpRetParams> *aA
void
nsHttpConnectionMgr::ResetIPFamillyPreference(nsHttpConnectionInfo *ci)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
nsConnectionEntry *ent = LookupConnectionEntry(ci, nullptr, nullptr);
if (ent)
ent->ResetIPFamilyPreference();
Expand Down
31 changes: 31 additions & 0 deletions netwerk/test/unit/test_freshconnection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// This is essentially a debug mode crashtest to make sure everything
// involved in a reload runs on the right thread. It relies on the
// assertions in necko.

const Cc = Components.classes;
const Ci = Components.interfaces;

var listener = {
onStartRequest: function test_onStartR(request, ctx) {
},

onDataAvailable: function test_ODA() {
do_throw("Should not get any data!");
},

onStopRequest: function test_onStopR(request, ctx, status) {
do_test_finished();
},
};

function run_test() {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var chan = ios.newChannel("http://localhost:4444", "", null);
chan.loadFlags = Ci.nsIRequest.LOAD_FRESH_CONNECTION |
Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
chan.QueryInterface(Ci.nsIHttpChannel);
chan.asyncOpen(listener, null);
do_test_pending();
}

1 change: 1 addition & 0 deletions netwerk/test/unit/xpcshell.ini
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ tail =
[test_file_partial_inputstream.js]
[test_file_protocol.js]
[test_filestreams.js]
[test_freshconnection.js]
[test_gre_resources.js]
[test_gzipped_206.js]
[test_head.js]
Expand Down

0 comments on commit b75c3e8

Please sign in to comment.