Bug 1481139 - fix GMP process IPC channel error on Android. r=jld,njn

Bug 1481139 - p1: handle invalid file descriptors.
Bug 1481139 - p2: add dummy fds for GMP process.

Two file descriptors were added in bug 1438678 and 1471025 for content/child
process but not GMP process, and it breaks the IPC channel on Android.

Add dummy values to make it work for now before bug 1440207 clean up the mess.

Differential Revision: https://phabricator.services.mozilla.com/D3541

--HG--
extra : moz-landing-system : lando
This commit is contained in:
John Lin 2018-08-17 00:06:20 +00:00
parent ba75ab7e22
commit a47eb60caa
3 changed files with 22 additions and 6 deletions

View file

@ -24,6 +24,8 @@ using std::string;
using mozilla::gmp::GMPProcessParent;
using mozilla::ipc::GeckoChildProcessHost;
static const int kInvalidFd = -1;
namespace mozilla {
namespace gmp {
@ -77,6 +79,12 @@ GMPProcessParent::Launch(int32_t aTimeoutMs)
args.push_back(mGMPPath);
#endif
#ifdef MOZ_WIDGET_ANDROID
// Add dummy values for pref and pref map to the file descriptors remapping
// table. See bug 1440207 and 1481139.
AddFdToRemap(kInvalidFd, kInvalidFd);
AddFdToRemap(kInvalidFd, kInvalidFd);
#endif
return SyncLaunch(args, aTimeoutMs);
}

View file

@ -204,8 +204,10 @@ public final class GeckoProcessManager extends IProcessManager.Stub {
}
final Bundle extras = GeckoThread.getActiveExtras();
final ParcelFileDescriptor prefsPfd = ParcelFileDescriptor.adoptFd(prefsFd);
final ParcelFileDescriptor prefMapPfd = ParcelFileDescriptor.adoptFd(prefMapFd);
final ParcelFileDescriptor prefsPfd =
(prefsFd >= 0) ? ParcelFileDescriptor.adoptFd(prefsFd) : null;
final ParcelFileDescriptor prefMapPfd =
(prefMapFd >= 0) ? ParcelFileDescriptor.adoptFd(prefMapFd) : null;
final ParcelFileDescriptor ipcPfd = ParcelFileDescriptor.adoptFd(ipcFd);
final ParcelFileDescriptor crashPfd =
(crashFd >= 0) ? ParcelFileDescriptor.adoptFd(crashFd) : null;
@ -228,8 +230,12 @@ public final class GeckoProcessManager extends IProcessManager.Stub {
crashPfd.detachFd();
}
ipcPfd.detachFd();
if (prefMapPfd != null) {
prefMapPfd.detachFd();
}
if (prefsPfd != null) {
prefsPfd.detachFd();
}
if (!started) {
if (retry) {

View file

@ -74,8 +74,10 @@ public class GeckoServiceChildProcess extends Service {
sProcessManager = procMan;
}
final int prefsFd = prefsPfd.detachFd();
final int prefMapFd = prefMapPfd.detachFd();
final int prefsFd = prefsPfd != null ?
prefsPfd.detachFd() : -1;
final int prefMapFd = prefMapPfd != null ?
prefMapPfd.detachFd() : -1;
final int ipcFd = ipcPfd.detachFd();
final int crashReporterFd = crashReporterPfd != null ?
crashReporterPfd.detachFd() : -1;