diff options
author | Andreas Huber <andih@google.com> | 2012-05-01 10:18:32 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2012-05-01 10:18:32 -0700 |
commit | 8b6bacd02a0478ed51b3b15a9e997624c95a7564 (patch) | |
tree | 19b0b2d814dbf49f429f145fb7aaf19ccb7c83cb /media | |
parent | 27431de020e535c31365884316f656bc60b4fe4f (diff) | |
download | frameworks_av-8b6bacd02a0478ed51b3b15a9e997624c95a7564.zip frameworks_av-8b6bacd02a0478ed51b3b15a9e997624c95a7564.tar.gz frameworks_av-8b6bacd02a0478ed51b3b15a9e997624c95a7564.tar.bz2 |
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
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp | 10 | ||||
-rw-r--r-- | media/libstagefright/chromium_http/support.cpp | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp index 76f7946..3f0b2c2 100644 --- a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp +++ b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp @@ -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(); } diff --git a/media/libstagefright/chromium_http/support.cpp b/media/libstagefright/chromium_http/support.cpp index f15014e..13ae3df 100644 --- a/media/libstagefright/chromium_http/support.cpp +++ b/media/libstagefright/chromium_http/support.cpp @@ -490,6 +490,10 @@ void SfDelegate::OnInitiateDisconnectWrapper(SfDelegate *me) { } void SfDelegate::onInitiateDisconnect() { + if (mURLRequest == NULL) { + return; + } + mURLRequest->Cancel(); delete mURLRequest; |