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

Commit 0660919c authored by Wei Wang's avatar Wei Wang Committed by android-build-merger
Browse files

Merge "Skip unnecessary sleep during shutdown" am: e3e4ec7c

am: 57f94aa4

Change-Id: I6eed1052bcf74bf46511ad879fdb1348e507f0f6
parents 6deffe3c 57f94aa4
Loading
Loading
Loading
Loading
+15 −15
Original line number Original line Diff line number Diff line
@@ -267,8 +267,6 @@ static void DumpUmountDebuggingInfo(bool dump_all) {


static UmountStat UmountPartitions(std::chrono::milliseconds timeout) {
static UmountStat UmountPartitions(std::chrono::milliseconds timeout) {
    Timer t;
    Timer t;
    UmountStat stat = UMOUNT_STAT_TIMEOUT;
    int retry = 0;
    /* data partition needs all pending writes to be completed and all emulated partitions
    /* data partition needs all pending writes to be completed and all emulated partitions
     * umounted.If the current waiting is not good enough, give
     * umounted.If the current waiting is not good enough, give
     * up and leave it to e2fsck after reboot to fix it.
     * up and leave it to e2fsck after reboot to fix it.
@@ -280,25 +278,27 @@ static UmountStat UmountPartitions(std::chrono::milliseconds timeout) {
            return UMOUNT_STAT_ERROR;
            return UMOUNT_STAT_ERROR;
        }
        }
        if (block_devices.size() == 0) {
        if (block_devices.size() == 0) {
            stat = UMOUNT_STAT_SUCCESS;
            return UMOUNT_STAT_SUCCESS;
            break;
        }
        if ((timeout < t.duration()) && retry > 0) {  // try umount at least once
            stat = UMOUNT_STAT_TIMEOUT;
            break;
        }
        }
        if (emulated_devices.size() > 0 &&
        bool unmount_done = true;
            std::all_of(emulated_devices.begin(), emulated_devices.end(),
        if (emulated_devices.size() > 0) {
                        [](auto& entry) { return entry.Umount(); })) {
            unmount_done = std::all_of(emulated_devices.begin(), emulated_devices.end(),
                                       [](auto& entry) { return entry.Umount(); });
            if (unmount_done) {
                sync();
                sync();
            }
            }
        for (auto& entry : block_devices) {
            entry.Umount();
        }
        }
        retry++;
        unmount_done = std::all_of(block_devices.begin(), block_devices.end(),
                                   [](auto& entry) { return entry.Umount(); }) &&
                       unmount_done;
        if (unmount_done) {
            return UMOUNT_STAT_SUCCESS;
        }
        if ((timeout < t.duration())) {  // try umount at least once
            return UMOUNT_STAT_TIMEOUT;
        }
        std::this_thread::sleep_for(100ms);
        std::this_thread::sleep_for(100ms);
    }
    }
    return stat;
}
}


static void KillAllProcesses() { android::base::WriteStringToFile("i", "/proc/sysrq-trigger"); }
static void KillAllProcesses() { android::base::WriteStringToFile("i", "/proc/sysrq-trigger"); }