[incfs] Fix a leaked pending_reads FD

Bug: 153670585
Test: adb install/uninstall a dozen times
Change-Id: Iac05b5dc3792e55c2f103ac08bdd734b3b398882
This commit is contained in:
Yurii Zubrytskyi
2020-04-09 18:24:51 -07:00
committed by Alex Buynytskyy
parent 6c6d81a121
commit 4e21986e59

View File

@@ -34,6 +34,8 @@ import android.os.ParcelFileDescriptor;
import android.util.ExceptionUtils; import android.util.ExceptionUtils;
import android.util.Slog; import android.util.Slog;
import libcore.io.IoUtils;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
@@ -115,22 +117,10 @@ public abstract class DataLoaderService extends Service {
destroy(id); destroy(id);
throw new RuntimeException(ex); throw new RuntimeException(ex);
} finally { } finally {
// Closing FDs.
if (control.incremental != null) { if (control.incremental != null) {
if (control.incremental.cmd != null) { IoUtils.closeQuietly(control.incremental.cmd);
try { IoUtils.closeQuietly(control.incremental.pendingReads);
control.incremental.cmd.close(); IoUtils.closeQuietly(control.incremental.log);
} catch (IOException e) {
Slog.e(TAG, "Failed to close IncFs CMD file descriptor " + e);
}
}
if (control.incremental.log != null) {
try {
control.incremental.log.close();
} catch (IOException e) {
Slog.e(TAG, "Failed to close IncFs LOG file descriptor " + e);
}
}
} }
} }
} }