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

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

Merge "Add timeout to lock in MtpServer configure" into oc-dev

parents 80158939 0475d911
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -490,7 +490,11 @@ int MtpFfsHandle::start() {

int MtpFfsHandle::configure(bool usePtp) {
    // Wait till previous server invocation has closed
    std::lock_guard<std::mutex> lk(mLock);
    if (!mLock.try_lock_for(std::chrono::milliseconds(1000))) {
        LOG(ERROR) << "MtpServer was unable to get configure lock";
        return -1;
    }
    int ret = 0;

    // If ptp is changed, the configuration must be rewritten
    if (mPtp != usePtp) {
@@ -500,10 +504,10 @@ int MtpFfsHandle::configure(bool usePtp) {
    mPtp = usePtp;

    if (!initFunctionfs()) {
        return -1;
        ret = -1;
    }

    return 0;
    mLock.unlock();
    return ret;
}

void MtpFfsHandle::close() {
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ private:

    bool mPtp;

    std::mutex mLock;
    std::timed_mutex mLock;

    android::base::unique_fd mControl;
    // "in" from the host's perspective => sink for mtp server