Commit 2e9ee3f8 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

android: Ignore calls to stopped connection

There is a race during an unexpected process death.
|rebind| and |updateGroupImportance| are called from content code which
are notified of process death through IPC code.
ChildProcessConnection is also notified of process death directly from
Android in onServiceDisconnected.

So it is possible Android notices the death and delivers the message
first while content code is still trying to access the connection.
Simply ignore these calls in that case.

Fixes: 1026626
Fixes: 1033577
Change-Id: I13eb65fb796e7a8999f781ae11df23c69d40161a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2031866Reviewed-by: default avatarssid <ssid@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738167}
parent 7c937b98
......@@ -161,13 +161,9 @@ public class ChildProcessConnection {
public void updateGroupImportance(int group, int importanceInGroup) {
assert isBound();
if (BindService.supportVariableConnections()) {
try {
ApiHelperForQ.updateServiceGroup(mContext, this, group, importanceInGroup);
BindService.doBindService(mContext, mBindIntent, this, mBindFlags, mHandler,
mExecutor, mInstanceName);
} catch (IllegalArgumentException e) {
// TODO(crbug.com/1026626): Stop ignoring this exception.
}
ApiHelperForQ.updateServiceGroup(mContext, this, group, importanceInGroup);
BindService.doBindService(mContext, mBindIntent, this, mBindFlags, mHandler,
mExecutor, mInstanceName);
}
}
......@@ -443,6 +439,7 @@ public class ChildProcessConnection {
*/
public void rebind() {
assert isRunningOnLauncherThread();
if (!isConnected()) return;
assert mWaivedBinding.isBound();
mWaivedBinding.bind();
}
......@@ -711,6 +708,7 @@ public class ChildProcessConnection {
public void updateGroupImportance(int group, int importanceInGroup) {
assert isRunningOnLauncherThread();
if (!isConnected()) return;
assert !mUnbound;
assert mWaivedBinding.isBound();
assert group != 0 || importanceInGroup == 0;
......
......@@ -463,9 +463,11 @@ public class ChildProcessConnectionTest {
}
@Test
public void testUpdateGroupImportanceSmoke() {
public void testUpdateGroupImportanceSmoke() throws RemoteException {
ChildProcessConnection connection = createDefaultTestConnection();
connection.start(false /* useStrongBinding */, null /* serviceCallback */);
when(mIChildProcessService.bindToCaller()).thenReturn(true);
mFirstServiceConnection.notifyServiceConnected(mChildProcessServiceBinder);
connection.updateGroupImportance(1, 2);
assertEquals(1, connection.getGroup());
assertEquals(2, connection.getImportanceInGroup());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment