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

Commit 96e35f2e authored by Andreas Huber's avatar Andreas Huber
Browse files

Don't hold onto the lock while reconnecting to the server

to avoid stalling the readers.

Change-Id: I73b646587c8a654a73ff7d800c0f17bd78001855
parent 421648ed
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -279,6 +279,8 @@ void NuCachedSource2::onMessageReceived(const sp<AMessage> &msg) {
void NuCachedSource2::fetchInternal() {
    LOGV("fetchInternal");

    bool reconnect = false;

    {
        Mutex::Autolock autoLock(mLock);
        CHECK(mFinalStatus == OK || mNumRetriesLeft > 0);
@@ -286,9 +288,16 @@ void NuCachedSource2::fetchInternal() {
        if (mFinalStatus != OK) {
            --mNumRetriesLeft;

            reconnect = true;
        }
    }

    if (reconnect) {
        status_t err =
            mSource->reconnectAtOffset(mCacheOffset + mCache->totalSize());

        Mutex::Autolock autoLock(mLock);

        if (err == ERROR_UNSUPPORTED) {
            mNumRetriesLeft = 0;
            return;
@@ -299,7 +308,6 @@ void NuCachedSource2::fetchInternal() {
            return;
        }
    }
    }

    PageCache::Page *page = mCache->acquirePage();