Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3efaf987 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi Committed by Automerger Merge Worker
Browse files

[incfs] Fix a leaked pending_reads FD am: 4e21986e

Change-Id: I726bf0ed15f144af87893f8b86b464c0d6bf6581
parents 2f8bead6 4e21986e
Loading
Loading
Loading
Loading
+5 −15
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import android.os.ParcelFileDescriptor;
import android.util.ExceptionUtils;
import android.util.Slog;

import libcore.io.IoUtils;

import java.io.IOException;
import java.util.Collection;

@@ -115,22 +117,10 @@ public abstract class DataLoaderService extends Service {
                destroy(id);
                throw new RuntimeException(ex);
            } finally {
                // Closing FDs.
                if (control.incremental != null) {
                    if (control.incremental.cmd != null) {
                        try {
                            control.incremental.cmd.close();
                        } 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);
                        }
                    }
                    IoUtils.closeQuietly(control.incremental.cmd);
                    IoUtils.closeQuietly(control.incremental.pendingReads);
                    IoUtils.closeQuietly(control.incremental.log);
                }
            }
        }