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

Commit e8840195 authored by Jerry Zhang's avatar Jerry Zhang Committed by android-build-merger
Browse files

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

am: f97ade32

Change-Id: Ib6f2cd6072826b3d25f0304760023ec2ab0eef75
parents 05d698d9 f97ade32
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