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
This commit is contained in:
edburns%acm.org
2001-02-13 22:19:12 +00:00
parent 063fc9c66f
commit fb9eb2800c
4 changed files with 9 additions and 15 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}