HTTPMediaIO: fix crash on exit.

- Remove custom BUrlContext, use the shared one to simplify ownership
  management. This means all HTTP media streams in an application share
  the same context (including cookies), however.
- Fix deletion of the BUrlRequest object, which cannot reliably happen
  before the thread has exited. RequestCompleted is too early.
This commit is contained in:
Adrien Destugues 2016-10-31 18:06:39 +01:00
parent 05574d9b2f
commit 98e33bf69a
2 changed files with 2 additions and 11 deletions

View File

@ -85,7 +85,6 @@ public:
return;
fRequest = NULL;
delete request;
}
status_t LockOnInit(bigtime_t timeout)
@ -119,7 +118,6 @@ private:
HTTPMediaIO::HTTPMediaIO(BUrl url)
:
BAdapterIO(B_MEDIA_STREAMING | B_MEDIA_SEEKABLE, HTTP_TIMEOUT),
fContext(NULL),
fReq(NULL),
fListener(NULL),
fReqThread(-1),
@ -127,10 +125,6 @@ HTTPMediaIO::HTTPMediaIO(BUrl url)
fIsMutable(false)
{
CALLED();
// The context has the same life time of the object
fContext = new BUrlContext();
fContext->AcquireReference();
}
@ -142,8 +136,7 @@ HTTPMediaIO::~HTTPMediaIO()
status_t status;
wait_for_thread(fReqThread, &status);
fContext->ReleaseReference();
delete fContext;
delete fReq;
}
@ -177,8 +170,7 @@ HTTPMediaIO::Open()
fListener = new FileListener(this);
fReq = BUrlProtocolRoster::MakeRequest(fUrl,
fListener, fContext);
fReq = BUrlProtocolRoster::MakeRequest(fUrl, fListener);
if (fReq == NULL)
return B_ERROR;

View File

@ -40,7 +40,6 @@ protected:
friend class FileListener;
private:
BUrlContext* fContext;
BUrlRequest* fReq;
FileListener* fListener;
thread_id fReqThread;