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

Commit 5046baaa authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Crash if too many open files"

parents 124d8abf 3d8df0e9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -362,6 +362,13 @@ sp<InputChannel> InputChannel::dup() const {
    if (!newFd.ok()) {
        ALOGE("Could not duplicate fd %i for channel %s: %s", getFd(), mName.c_str(),
              strerror(errno));
        const bool hitFdLimit = errno == EMFILE || errno == ENFILE;
        // If this process is out of file descriptors, then throwing that might end up exploding
        // on the other side of a binder call, which isn't really helpful.
        // Better to just crash here and hope that the FD leak is slow.
        // Other failures could be client errors, so we still propagate those back to the caller.
        LOG_ALWAYS_FATAL_IF(hitFdLimit, "Too many open files, could not duplicate input channel %s",
                            getName().c_str());
        return nullptr;
    }
    return InputChannel::create(mName, std::move(newFd));