From fb9eb2800cc6ec3abd940189218f4ca054373525 Mon Sep 17 00:00:00 2001 From: "edburns%acm.org" Date: Tue, 13 Feb 2001 22:19:12 +0000 Subject: [PATCH] bug=49797 r=ashuk The following files are in the fix for this bug: M CBrowserContainer.cpp M CurrentPageImpl.cpp M HistoryImpl.cpp M NavigationImpl.cpp Here is the reason for the bug: User presses "Refresh" button. This causes the following code to be executed: public void refresh(long loadFlags) { ParameterCheck.noLessThan(loadFlags, 0); myFactory.throwExceptionIfNotInitialized(); Assert.assert(-1 != nativeWebShell); synchronized(myBrowserControl) { nativeRefresh(nativeWebShell, loadFlags); } } In the process of refresh, on another thread, the user's eventDispatched() method is called, which calls history.canBack(): public boolean canBack() { myFactory.throwExceptionIfNotInitialized(); Assert.assert(-1 != nativeWebShell); boolean result = false; synchronized(myBrowserControl) { result = nativeCanBack(nativeWebShell); } return result; } This call blocks on trying to acquire the lock for myBrowserControl, and the load can't proceed until canBack() returns. DEADLOCK. ------------- The fix is to use PostEvent instead of PostSynchronous event. This causes the call to nativeRefresh to return immediately. git-svn-id: svn://10.0.0.236/branches/JAVADEV_RTM_20001102@86938 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/java/webclient/src_moz/CBrowserContainer.cpp | 12 ++++-------- mozilla/java/webclient/src_moz/CurrentPageImpl.cpp | 2 +- mozilla/java/webclient/src_moz/HistoryImpl.cpp | 7 +++---- mozilla/java/webclient/src_moz/NavigationImpl.cpp | 3 +-- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/mozilla/java/webclient/src_moz/CBrowserContainer.cpp b/mozilla/java/webclient/src_moz/CBrowserContainer.cpp index e2bcef56956..505f4ea656f 100644 --- a/mozilla/java/webclient/src_moz/CBrowserContainer.cpp +++ b/mozilla/java/webclient/src_moz/CBrowserContainer.cpp @@ -180,7 +180,6 @@ NS_IMETHODIMP CBrowserContainer::PromptUsernameAndPassword(const PRUnichar *dial JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION); wsPromptUsernameAndPasswordEvent *actionEvent = nsnull; - void *voidResult = nsnull; wsStringStruct strings[3] = { {dialogTitle, nsnull}, @@ -223,10 +222,9 @@ NS_IMETHODIMP CBrowserContainer::PromptUsernameAndPassword(const PRUnichar *dial goto PUAP_CLEANUP; } // the out params to this method are set in wsPromptUsernameAndPasswordEvent::handleEvent() - voidResult = ::util_PostSynchronousEvent(mInitContext, + ::util_PostEvent(mInitContext, (PLEvent *) *actionEvent); - - rv = (nsresult) voidResult; + rv = NS_OK; PUAP_CLEANUP: ::util_DeleteJstringsFromUnichars(strings, 3); @@ -281,7 +279,6 @@ CBrowserContainer::UniversalDialog(const PRUnichar *inTitleMessage, JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION); wsPromptUniversalDialogEvent *actionEvent = nsnull; - void *voidResult = nsnull; wsStringStruct strings[10] = { {inTitleMessage, nsnull}, @@ -338,10 +335,9 @@ CBrowserContainer::UniversalDialog(const PRUnichar *inTitleMessage, goto UD_CLEANUP; } // the out params to this method are set in wsPromptUsernameAndPasswordEvent::handleEvent() - voidResult = ::util_PostSynchronousEvent(mInitContext, - (PLEvent *) *actionEvent); + ::util_PostEvent(mInitContext, (PLEvent *) *actionEvent); - rv = (nsresult) voidResult; + rv = NS_OK; UD_CLEANUP: ::util_DeleteJstringsFromUnichars(strings, 10); diff --git a/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp b/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp index be453943e6a..000a3025101 100644 --- a/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp +++ b/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp @@ -348,7 +348,7 @@ JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentP new wsViewSourceEvent(initContext->docShell, ((JNI_TRUE == viewMode)? PR_TRUE : PR_FALSE)); PLEvent * event = (PLEvent*) *actionEvent; - ::util_PostSynchronousEvent(initContext, event); + ::util_PostEvent(initContext, event); } jbyteArray result = nsnull; diff --git a/mozilla/java/webclient/src_moz/HistoryImpl.cpp b/mozilla/java/webclient/src_moz/HistoryImpl.cpp index 5e24d4152dc..df6c93b8188 100644 --- a/mozilla/java/webclient/src_moz/HistoryImpl.cpp +++ b/mozilla/java/webclient/src_moz/HistoryImpl.cpp @@ -51,7 +51,7 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeBack new wsBackEvent(initContext->webNavigation); PLEvent * event = (PLEvent*) *actionEvent; - ::util_PostSynchronousEvent(initContext, event); + ::util_PostEvent(initContext, event); } return; @@ -120,7 +120,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_na new wsForwardEvent(initContext->webNavigation); PLEvent * event = (PLEvent*) *actionEvent; - ::util_PostSynchronousEvent(initContext, event); + ::util_PostEvent(initContext, event); } return; @@ -214,7 +214,6 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeSetCurrentHistoryIn { JNIEnv * pEnv = env; jobject jobj = obj; - void * voidResult = nsnull; WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; @@ -228,7 +227,7 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeSetCurrentHistoryIn new wsGoToEvent(initContext->webNavigation, historyIndex); PLEvent * event = (PLEvent*) *actionEvent; - voidResult = ::util_PostSynchronousEvent(initContext, event); + ::util_PostEvent(initContext, event); } return; diff --git a/mozilla/java/webclient/src_moz/NavigationImpl.cpp b/mozilla/java/webclient/src_moz/NavigationImpl.cpp index 86e6ebd2ef8..378e22b7c81 100644 --- a/mozilla/java/webclient/src_moz/NavigationImpl.cpp +++ b/mozilla/java/webclient/src_moz/NavigationImpl.cpp @@ -150,7 +150,6 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl { JNIEnv * pEnv = env; jobject jobj = obj; - void * voidResult = nsnull; WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; @@ -163,7 +162,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl wsRefreshEvent * actionEvent = new wsRefreshEvent(initContext->webNavigation, (PRInt32) loadFlags); PLEvent * event = (PLEvent*) *actionEvent; - voidResult = ::util_PostSynchronousEvent(initContext, event); + ::util_PostEvent(initContext, event); return; }