mozilla / audioipc

Cubeb Audio Remoting For Gecko
10 stars 17 forks source link

Refactor shared ArrayQueue logic into RequestQueue wrapper. #166

Closed kinetiknz closed 1 year ago

kinetiknz commented 1 year ago

This centralises the handling of Weak->Arc upgrades when sending, and avoids a footgun where the sender could keep the RequestQueue alive while waiting for a request to complete.

The existing code made this exact mistake: upgrading Weak->Arc, sending a request, and then waiting on the response while the upgraded Arc remained in scope. The sender must drop the Arc after queuing the request and before waiting on the response to avoid the situation where the request is successfully queued while the server is shutting down - resulting in the queued Requests never being dropped and the sender becoming deadlocked.