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

Commit 4f17dadd authored by Robert Shih's avatar Robert Shih
Browse files

NuCachedSource2: fix disconnect process

 - clear mAsyncResult
 - return early from reads if mDisconnecting is set

Bug: 17696761
Change-Id: I98bfc3f5f06594915bd58faf71fbcded482664d2
parent a8a4eeb9
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -456,6 +456,10 @@ void NuCachedSource2::onRead(const sp<AMessage> &msg) {
    }

    Mutex::Autolock autoLock(mLock);
    if (mDisconnecting) {
        mCondition.signal();
        return;
    }

    CHECK(mAsyncResult == NULL);

@@ -502,6 +506,9 @@ ssize_t NuCachedSource2::readAt(off64_t offset, void *data, size_t size) {
    ALOGV("readAt offset %lld, size %zu", offset, size);

    Mutex::Autolock autoLock(mLock);
    if (mDisconnecting) {
        return ERROR_END_OF_STREAM;
    }

    // If the request can be completely satisfied from the cache, do so.

@@ -528,6 +535,7 @@ ssize_t NuCachedSource2::readAt(off64_t offset, void *data, size_t size) {
    }

    if (mDisconnecting) {
        mAsyncResult.clear();
        return ERROR_END_OF_STREAM;
    }