From 98e33bf69a53aef51165f3581fba2fd7fb784749 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 31 Oct 2016 18:06:39 +0100 Subject: [PATCH] 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. --- .../media/plugins/http_streamer/HTTPMediaIO.cpp | 12 ++---------- .../media/plugins/http_streamer/HTTPMediaIO.h | 1 - 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.cpp b/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.cpp index 7166c8b22e..837e9a89f5 100644 --- a/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.cpp +++ b/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.cpp @@ -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; diff --git a/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h b/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h index f348ef8f64..e917391d24 100644 --- a/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h +++ b/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h @@ -40,7 +40,6 @@ protected: friend class FileListener; private: - BUrlContext* fContext; BUrlRequest* fReq; FileListener* fListener; thread_id fReqThread;