зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
ec313f69b9
Коммит
461f05b3f0
|
@ -46,6 +46,8 @@
|
||||||
#include "nsHtml5TreeBuilder.h"
|
#include "nsHtml5TreeBuilder.h"
|
||||||
#include "nsHtml5UTF16Buffer.h"
|
#include "nsHtml5UTF16Buffer.h"
|
||||||
#include "nsHtml5Module.h"
|
#include "nsHtml5Module.h"
|
||||||
|
#include "nsIObserverService.h"
|
||||||
|
#include "nsIServiceManager.h"
|
||||||
|
|
||||||
// static
|
// static
|
||||||
PRBool nsHtml5Module::sEnabled = PR_FALSE;
|
PRBool nsHtml5Module::sEnabled = PR_FALSE;
|
||||||
|
@ -90,9 +92,6 @@ nsHtml5Module::ReleaseStatics()
|
||||||
nsHtml5Tokenizer::releaseStatics();
|
nsHtml5Tokenizer::releaseStatics();
|
||||||
nsHtml5TreeBuilder::releaseStatics();
|
nsHtml5TreeBuilder::releaseStatics();
|
||||||
nsHtml5UTF16Buffer::releaseStatics();
|
nsHtml5UTF16Buffer::releaseStatics();
|
||||||
if (sStreamParserThread) {
|
|
||||||
sStreamParserThread->Shutdown();
|
|
||||||
}
|
|
||||||
NS_IF_RELEASE(sStreamParserThread);
|
NS_IF_RELEASE(sStreamParserThread);
|
||||||
NS_IF_RELEASE(sMainThread);
|
NS_IF_RELEASE(sMainThread);
|
||||||
}
|
}
|
||||||
|
@ -116,6 +115,29 @@ nsHtml5Module::Initialize(nsIParser* aParser, nsIDocument* aDoc, nsIURI* aURI, n
|
||||||
return parser->Initialize(aDoc, aURI, aContainer, aChannel);
|
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
|
// static
|
||||||
nsIThread*
|
nsIThread*
|
||||||
nsHtml5Module::GetStreamParserThread()
|
nsHtml5Module::GetStreamParserThread()
|
||||||
|
@ -124,6 +146,11 @@ nsHtml5Module::GetStreamParserThread()
|
||||||
if (!sStreamParserThread) {
|
if (!sStreamParserThread) {
|
||||||
NS_NewThread(&sStreamParserThread);
|
NS_NewThread(&sStreamParserThread);
|
||||||
NS_ASSERTION(sStreamParserThread, "Thread creation failed!");
|
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;
|
return sStreamParserThread;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ _TEST_FILES = parser_datreader.js \
|
||||||
test_bug396568.html \
|
test_bug396568.html \
|
||||||
test_bug418464.html \
|
test_bug418464.html \
|
||||||
test_bug460437.xhtml \
|
test_bug460437.xhtml \
|
||||||
|
test_bug502091.html \
|
||||||
bug_502091_iframe.html \
|
bug_502091_iframe.html \
|
||||||
test_compatmode.html \
|
test_compatmode.html \
|
||||||
regressions.txt \
|
regressions.txt \
|
||||||
|
@ -65,6 +66,3 @@ _TEST_FILES = parser_datreader.js \
|
||||||
|
|
||||||
libs:: $(_TEST_FILES)
|
libs:: $(_TEST_FILES)
|
||||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
|
$(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){
|
function test(mode,i){
|
||||||
is(mode,doctypes[i],doctypes[i+1]);
|
is(mode,doctypes[i],doctypes[i+1]);
|
||||||
if (i == doctypes.length - 2) {
|
if (i == doctypes.length - 2) {
|
||||||
// if (typeof(gOriginalHtml5Pref) == "undefined") {
|
if (typeof(gOriginalHtml5Pref) == "undefined") {
|
||||||
// doTestHtml5(); Disabled due to bug 529544
|
doTestHtml5();
|
||||||
// }
|
}
|
||||||
// else {
|
else {
|
||||||
finishTest();
|
finishTest();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче