Duplicate file descriptor when dumping asynchronously.

dumpDbInfo() uses an async task when dumping from the system thread, but
then the file descriptor is closed by the time the task is executed. As
such, the system databases are not dumped.

BUG: 29123428
Change-Id: Ibb8bbe503aa03c3ca13b2b1789f0ead0b869e9d5
This commit is contained in:
Felipe Leme
2016-06-07 16:14:07 -07:00
parent a86d6c4df3
commit 29de4922db

View File

@@ -1166,12 +1166,22 @@ public final class ActivityThread {
@Override
public void dumpDbInfo(final FileDescriptor fd, final String[] args) {
if (mSystemThread) {
// Ensure this invocation is asynchronous to prevent
// writer waiting due to buffer cannot be consumed.
// Ensure this invocation is asynchronous to prevent writer waiting if buffer cannot
// be consumed. But it must duplicate the file descriptor first, since caller might
// be closing it.
final ParcelFileDescriptor dup;
try {
dup = ParcelFileDescriptor.dup(fd);
} catch (IOException e) {
Log.w(TAG, "Could not dup FD " + fd.getInt$());
return;
}
AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
@Override
public void run() {
dumpDatabaseInfo(fd, args);
dumpDatabaseInfo(dup.getFileDescriptor(), args);
IoUtils.closeQuietly(dup);
}
});
} else {