Bug 1105468 - OpenFileAndSendFDRunnable::OpenFile needs to ensure we don't release off main thread. r=bent

This commit is contained in:
Andrew McCreight 2015-01-09 13:10:14 -08:00
Родитель 762d9b52df
Коммит 53d885d990
1 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -171,7 +171,8 @@ private:
}
}
void OpenFile()
// Helper method to avoid gnarly control flow for failures.
void OpenFileImpl()
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(!mFD);
@ -185,10 +186,21 @@ private:
NS_ENSURE_SUCCESS_VOID(rv);
mFD = fd;
}
void OpenFile()
{
MOZ_ASSERT(!NS_IsMainThread());
OpenFileImpl();
if (NS_FAILED(NS_DispatchToMainThread(this))) {
NS_WARNING("Failed to dispatch to main thread!");
// Intentionally leak the runnable (but not the fd) rather
// than crash when trying to release a main thread object
// off the main thread.
mTabParent.forget();
CloseFile();
}
}