Bug 529544 - Shut down the HTML5 parser thread from an observer (random crash [@ mozilla::storage::Connection::Close()]). r=sdwilsh.

--HG--
extra : rebase_source : b63735cb935261066b0836d451967a87a5c22929
This commit is contained in:
Henri Sivonen 2009-11-24 14:28:18 +02:00
Родитель ec313f69b9
Коммит 461f05b3f0
3 изменённых файлов: 36 добавлений и 11 удалений

Просмотреть файл

@ -46,6 +46,8 @@
#include "nsHtml5TreeBuilder.h"
#include "nsHtml5UTF16Buffer.h"
#include "nsHtml5Module.h"
#include "nsIObserverService.h"
#include "nsIServiceManager.h"
// static
PRBool nsHtml5Module::sEnabled = PR_FALSE;
@ -90,9 +92,6 @@ nsHtml5Module::ReleaseStatics()
nsHtml5Tokenizer::releaseStatics();
nsHtml5TreeBuilder::releaseStatics();
nsHtml5UTF16Buffer::releaseStatics();
if (sStreamParserThread) {
sStreamParserThread->Shutdown();
}
NS_IF_RELEASE(sStreamParserThread);
NS_IF_RELEASE(sMainThread);
}
@ -116,6 +115,29 @@ nsHtml5Module::Initialize(nsIParser* aParser, nsIDocument* aDoc, nsIURI* aURI, n
return parser->Initialize(aDoc, aURI, aContainer, aChannel);
}
class nsHtml5ParserThreadTerminator : public nsIObserver
{
public:
NS_DECL_ISUPPORTS
nsHtml5ParserThreadTerminator(nsIThread* aThread)
: mThread(aThread)
{}
NS_IMETHODIMP Observe(nsISupports *, const char *topic, const PRUnichar *)
{
NS_ASSERTION(!strcmp(topic, "xpcom-shutdown-threads"),
"Unexpected topic");
if (mThread) {
mThread->Shutdown();
mThread = nsnull;
}
return NS_OK;
}
private:
nsCOMPtr<nsIThread> mThread;
};
NS_IMPL_ISUPPORTS1(nsHtml5ParserThreadTerminator, nsIObserver)
// static
nsIThread*
nsHtml5Module::GetStreamParserThread()
@ -124,6 +146,11 @@ nsHtml5Module::GetStreamParserThread()
if (!sStreamParserThread) {
NS_NewThread(&sStreamParserThread);
NS_ASSERTION(sStreamParserThread, "Thread creation failed!");
nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");
NS_ASSERTION(os, "do_GetService failed");
os->AddObserver(new nsHtml5ParserThreadTerminator(sStreamParserThread),
"xpcom-shutdown-threads",
PR_FALSE);
}
return sStreamParserThread;
}

Просмотреть файл

@ -57,6 +57,7 @@ _TEST_FILES = parser_datreader.js \
test_bug396568.html \
test_bug418464.html \
test_bug460437.xhtml \
test_bug502091.html \
bug_502091_iframe.html \
test_compatmode.html \
regressions.txt \
@ -65,6 +66,3 @@ _TEST_FILES = parser_datreader.js \
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
# Disabled due to bug 529544
# test_bug502091.html \

Просмотреть файл

@ -77,12 +77,12 @@ function finishTest() {
function test(mode,i){
is(mode,doctypes[i],doctypes[i+1]);
if (i == doctypes.length - 2) {
// if (typeof(gOriginalHtml5Pref) == "undefined") {
// doTestHtml5(); Disabled due to bug 529544
// }
// else {
if (typeof(gOriginalHtml5Pref) == "undefined") {
doTestHtml5();
}
else {
finishTest();
// }
}
}
}