Media Kit: BBufferCache: if not reclaimed, only mark the buffer for deletion

hrev53379 clears the buffer cache for disconnected clients, and also delete buffers.
This is too early (see #15263, media_addon_server crash), and should only happen
after the buffer is recycled. This can be resolved by abusing the fFlags field of
BBuffer to mark the buffer for deletion, and mark the buffer to be reclaimed.
Some BBuffers don't reside in the SharedBufferList, so we have to mark them as to
be reclaimed. For those in the SharedBufferList, call a new RemoveBuffer(), which
can check whether the buffer is still to be reclaimed. For reclaimed BBuffers,
delete them right away, others can be marked for deletion.
fixes #15606 #15263, possibly #15433

Change-Id: I66e94138e7e10a40d4c48e2ac042f816c79f5aab
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2245
Reviewed-by: Adrien Destugues <[email protected]>
Reviewed-by: X512 <[email protected]>
Reviewed-by: Ryan Leavengood <[email protected]>
This commit is contained in:
Jérôme Duval
2020-02-16 08:38:49 +00:00
committed by Adrien Destugues
parent 0dde5052bb
commit 9c9a810c41
5 changed files with 70 additions and 4 deletions
+4
View File
@@ -44,6 +44,10 @@ progress_shutdown(int stage,
#define MEDIA_SERVER_PORT_NAME "__media_server_port"
#define MEDIA_ADDON_SERVER_PORT_NAME "__media_addon_server_port"
#define BUFFER_TO_RECLAIM 0x20000000
#define BUFFER_MARKED_FOR_DELETION 0x40000000
extern const char *B_MEDIA_ADDON_SERVER_SIGNATURE;
namespace BPrivate { namespace media {
+1
View File
@@ -30,6 +30,7 @@ public:
status_t AddBuffer(sem_id groupReclaimSem,
const buffer_clone_info& info,
BBuffer** buffer);
status_t RemoveBuffer(BBuffer* buffer);
// Call AddBuffer and CheckID locked
status_t AddBuffer(sem_id groupReclaimSem,