зеркало из https://github.com/mozilla/gecko-dev.git
Branch landing: Multithreading in mozilla.
- Move JSCF_Execute to the mocha thread. - Add JS_BeginRequest and JS_EndRequest for thread safety.
This commit is contained in:
Родитель
83354ceddb
Коммит
4f9004db76
|
@ -377,6 +377,7 @@ initializeJSCookieFilterStuff()
|
|||
|| !filter_context)
|
||||
return NULL;
|
||||
|
||||
JS_BeginRequest(filter_context);
|
||||
/* create our "global" object. We make the message object a child of this */
|
||||
filter_obj = JS_NewObject(filter_context, &global_class, NULL, NULL);
|
||||
|
||||
|
@ -384,10 +385,12 @@ initializeJSCookieFilterStuff()
|
|||
if (!filter_obj
|
||||
|| !JS_DefineFunctions(filter_context, filter_obj, filter_methods))
|
||||
{
|
||||
JS_EndRequest(filter_context);
|
||||
destroyJSCookieFilterStuff();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JS_EndRequest(filter_context);
|
||||
return filter_context;
|
||||
}
|
||||
|
||||
|
@ -538,12 +541,16 @@ JSCF_Execute(
|
|||
if (!initializeJSCookieFilterStuff())
|
||||
return JSCF_error;
|
||||
|
||||
JS_BeginRequest(filter_context);
|
||||
|
||||
/*
|
||||
* try loading (reloading if necessary) the filter file before bothering
|
||||
* to create any JS-objects
|
||||
*/
|
||||
if (!compileJSCookieFilters())
|
||||
if (!compileJSCookieFilters()) {
|
||||
JS_EndRequest(filter_context);
|
||||
return JSCF_error;
|
||||
}
|
||||
|
||||
if (!error_reporter_installed)
|
||||
{
|
||||
|
@ -554,8 +561,10 @@ JSCF_Execute(
|
|||
|
||||
|
||||
cookie_obj = newCookieObject();
|
||||
if( (JSObject *)0 == cookie_obj )
|
||||
if( (JSObject *)0 == cookie_obj ) {
|
||||
JS_EndRequest(filter_context);
|
||||
return JSCF_error;
|
||||
}
|
||||
|
||||
cookie_data = (JSCookieData *)JS_GetPrivate(filter_context, cookie_obj);
|
||||
cookie_data->js_context = filter_context;
|
||||
|
@ -570,6 +579,8 @@ JSCF_Execute(
|
|||
JS_CallFunctionName(filter_context, filter_obj, script_name, 1,
|
||||
&filter_arg, &result);
|
||||
|
||||
JS_EndRequest(filter_context);
|
||||
|
||||
*data_changed = cookie_data->property_changed;
|
||||
if( cookie_data->decision_made ) {
|
||||
if( cookie_data->rejected )
|
||||
|
@ -592,6 +603,7 @@ JSCF_Cleanup(void)
|
|||
|
||||
if (filter_context)
|
||||
{
|
||||
JS_BeginRequest(filter_context);
|
||||
if (error_reporter_installed)
|
||||
{
|
||||
error_reporter_installed = JS_FALSE;
|
||||
|
@ -601,5 +613,6 @@ JSCF_Cleanup(void)
|
|||
JS_GC(filter_context);
|
||||
|
||||
destroyJSCookieFilterStuff();
|
||||
JS_EndRequest(filter_context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -781,6 +781,8 @@ NET_InitPacfContext(void)
|
|||
||(PREF_OK != PREF_GetGlobalConfigObject(&globalConfig)) )
|
||||
return FALSE;
|
||||
|
||||
JS_BeginRequest(configContext);
|
||||
|
||||
proxyConfig = JS_DefineObject(configContext, globalConfig,
|
||||
"ProxyConfig",
|
||||
&pc_class,
|
||||
|
@ -790,12 +792,14 @@ NET_InitPacfContext(void)
|
|||
if (!JS_DefineProperties(configContext,
|
||||
proxyConfig,
|
||||
pc_props)) {
|
||||
JS_EndRequest(configContext);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!JS_DefineFunctions(configContext,
|
||||
proxyConfig,
|
||||
pc_methods)) {
|
||||
JS_EndRequest(configContext);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -807,6 +811,8 @@ NET_InitPacfContext(void)
|
|||
NULL,
|
||||
0);
|
||||
|
||||
JS_EndRequest(configContext);
|
||||
|
||||
first_time = FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
@ -850,9 +856,11 @@ retry:
|
|||
goto out;
|
||||
}
|
||||
|
||||
JS_BeginRequest(configContext);
|
||||
ok = JS_EvaluateScript(configContext, proxyConfig,
|
||||
pacf_src_buf, pacf_src_len, pacf_url, 0,
|
||||
&result);
|
||||
JS_EndRequest(configContext);
|
||||
|
||||
if (!ok) {
|
||||
/* Something went wrong with the js evaluation. If we're using a
|
||||
|
@ -1194,8 +1202,11 @@ MODULE_PRIVATE char *pacf_find_proxies_for_url(MWContext *context,
|
|||
method ? method : "" );
|
||||
}
|
||||
|
||||
if (!JS_AddRoot(configContext, &rv))
|
||||
JS_BeginRequest(configContext);
|
||||
if (!JS_AddRoot(configContext, &rv)) {
|
||||
JS_EndRequest(configContext);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ( NET_FindProxyInJSC() ) {
|
||||
ok = JS_EvaluateScript(configContext, globalConfig,
|
||||
|
@ -1215,6 +1226,7 @@ MODULE_PRIVATE char *pacf_find_proxies_for_url(MWContext *context,
|
|||
}
|
||||
|
||||
JS_RemoveRoot(configContext, &rv);
|
||||
JS_EndRequest(configContext);
|
||||
out:
|
||||
FREEIF(method);
|
||||
FREEIF(buf);
|
||||
|
|
Загрузка…
Ссылка в новой задаче