diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-03 23:13:24 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-03 23:13:24 +0000 |
commit | c685b2c9143b873e7a55d2276a1476a3da5afe36 (patch) | |
tree | e10b8557b761b5487574e5567c5a8dd8bf80d999 /webkit | |
parent | 74963e1a14c5638162554943f04de03e5a3c85c6 (diff) | |
download | chromium_src-c685b2c9143b873e7a55d2276a1476a3da5afe36.zip chromium_src-c685b2c9143b873e7a55d2276a1476a3da5afe36.tar.gz chromium_src-c685b2c9143b873e7a55d2276a1476a3da5afe36.tar.bz2 |
Fix potential crash when multiple workers try to start at the same time. In our worker processs, we do not run any WebKit code in main thread. Thus when multiple workers try to start at the same time, we might hit crash due to contention for initializing static values. The fix is to do the initialization first in main thread of worker process.
Review URL: http://codereview.chromium.org/60099
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13125 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/webworker_impl.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/webkit/glue/webworker_impl.cc b/webkit/glue/webworker_impl.cc index 4b4ae94..7d32398 100644 --- a/webkit/glue/webworker_impl.cc +++ b/webkit/glue/webworker_impl.cc @@ -7,7 +7,9 @@ #include "base/compiler_specific.h" #include "GenericWorkerTask.h" +#include "KURL.h" #include "ScriptExecutionContext.h" +#include "SecurityOrigin.h" #include "WorkerContext.h" #include "WorkerThread.h" #include <wtf/Threading.h> @@ -27,7 +29,23 @@ WebWorker* WebWorker::Create(WebWorkerClient* client) { } +// This function is called on the main thread to force to initialize some static +// values used in WebKit before any worker thread is started. This is because in +// our worker processs, we do not run any WebKit code in main thread and thus +// when multiple workers try to start at the same time, we might hit crash due +// to contention for initializing static values. +void InitializeWebKitStaticValues() { + static bool initialized = false; + if (!initialized) { + initialized= true; + WTF::RefPtr<WebCore::SecurityOrigin> origin = + WebCore::SecurityOrigin::create(WebCore::KURL()); + origin.release(); + } +} + WebWorkerImpl::WebWorkerImpl(WebWorkerClient* client) : client_(client) { + InitializeWebKitStaticValues(); } WebWorkerImpl::~WebWorkerImpl() { |