From 3cb28080cf9dab7c8dae5519baca65c15a0213e4 Mon Sep 17 00:00:00 2001 From: "dbragg%netscape.com" Date: Fri, 25 May 2001 17:52:09 +0000 Subject: [PATCH] Fix for bug 78428. The call to AddSubcomponent which adds files has to be bracketed by JS_SuspendRequest and JS_ResumeRequest to prevent deadlock conditions. r/sr=brendan@mozilla.org, a=asa@mozilla.org --- xpinstall/src/nsJSInstall.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/xpinstall/src/nsJSInstall.cpp b/xpinstall/src/nsJSInstall.cpp index 45ddb7f9fb8..0af792facf1 100644 --- a/xpinstall/src/nsJSInstall.cpp +++ b/xpinstall/src/nsJSInstall.cpp @@ -542,6 +542,7 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js JSObject* jsObj; nsInstallFolder* folder; PRInt32 flags = 0; + nsresult rv; *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR); @@ -586,10 +587,12 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj); - if(NS_OK != nativeThis->AddSubcomponent(b0, b1, b2, folder, b4, flags, &nativeRet)) - { - return JS_FALSE; - } + //jsrefcount saveDepth; + //saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs + rv= nativeThis->AddSubcomponent(b0, b1, b2, folder, b4, flags, &nativeRet); + //JS_ResumeRequest(cx, saveDepth); + if (NS_FAILED(rv)) + return JS_FALSE; *rval = INT_TO_JSVAL(nativeRet); } @@ -624,10 +627,12 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj); - if(NS_OK != nativeThis->AddSubcomponent(b0, b1, b2, folder, b4, &nativeRet)) - { + //jsrefcount saveDepth; + //saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs + rv = nativeThis->AddSubcomponent(b0, b1, b2, folder, b4, &nativeRet); + //JS_ResumeRequest(cx, saveDepth); + if (NS_FAILED(rv)) return JS_FALSE; - } *rval = INT_TO_JSVAL(nativeRet); } @@ -794,7 +799,11 @@ InstallExecute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva { // public int Execute ( String jarSourcePath); ConvertJSValToStr(b0, cx, argv[0]); + + jsrefcount saveDepth; + saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs nativeThis->Execute(b0, b1, blocking, &nativeRet); + JS_ResumeRequest(cx, saveDepth); *rval = INT_TO_JSVAL(nativeRet); }