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

Commit 8b6bacd0 authored by Andreas Huber's avatar Andreas Huber
Browse files

Properly handle the case where a pending connection process is disconnected

just at the time when the connection is established.

Change-Id: Icbae5a61edfd6a1336e4b8d3ee513337363c09ea
related-to-bug: 6154825
parent 27431de0
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ status_t ChromiumHTTPDataSource::connect_l(

    mDelegate->initiateConnection(mURI.c_str(), &mHeaders, offset);

    while (mState == CONNECTING) {
    while (mState == CONNECTING || mState == DISCONNECTING) {
        mCondition.wait(mLock);
    }

@@ -110,6 +110,13 @@ status_t ChromiumHTTPDataSource::connect_l(
void ChromiumHTTPDataSource::onConnectionEstablished(
        int64_t contentSize, const char *contentType) {
    Mutex::Autolock autoLock(mLock);

    if (mState != CONNECTING) {
        // We may have initiated disconnection.
        CHECK_EQ(mState, DISCONNECTING);
        return;
    }

    mState = CONNECTED;
    mContentSize = (contentSize < 0) ? -1 : contentSize + mCurrentOffset;
    mContentType = String8(contentType);
@@ -255,6 +262,7 @@ void ChromiumHTTPDataSource::onDisconnectComplete() {

    mState = DISCONNECTED;
    // mURI.clear();
    mIOResult = -ENOTCONN;

    mCondition.broadcast();
}
+4 −0
Original line number Diff line number Diff line
@@ -490,6 +490,10 @@ void SfDelegate::OnInitiateDisconnectWrapper(SfDelegate *me) {
}

void SfDelegate::onInitiateDisconnect() {
    if (mURLRequest == NULL) {
        return;
    }

    mURLRequest->Cancel();

    delete mURLRequest;