Fix AVDTP endpoint resource leak by clearing the in_use flag on strea…#923
Fix AVDTP endpoint resource leak by clearing the in_use flag on strea…#923laozhuxinlu wants to merge 1 commit into
Conversation
…m close and abort commands.
|
|
||
| if self.rtp_channel is None: | ||
| # No channel to release, we're done | ||
| self.local_endpoint.in_use = 0 |
There was a problem hiding this comment.
It seems in_use is always used to determine whether configure is allowed for the stream endpoint, which is logically equal to stream.state == State.IDLE, since in the AVDTP spec, IDLE is the only state which allows setting configuration.
However, another fact is that we release streams very implicitly - only on another configuration procedure, and this requires in_use == 0.
I think we should have a more aligned and clear lifecycle for streams and local endpoints.
Maybe we can declare in_use as a property = self.stream is not None and self.stream.state == State.IDLE?
We may also clean up protocol.streams table when stream state transitted to IDLE.
There was a problem hiding this comment.
Another solution is just to remove in_use attribute and always consider streams in use, so we only need to properly remove them on release.
Fix an AVDTP endpoint resource leak where the
in_use flagwas not cleared if a stream was closed or aborted before the RTP channel was established. Previously, this caused the endpoint to remain permanently locked, improperly rejecting subsequent SetConfiguration attempts with a SEP_IN_USE error. This patch ensures local_endpoint.in_use is properly reset to 0 when transitioning directly to the IDLE state. Additionally, it wires up the missing local endpoint event trigger for Abort commands to properly notify application listeners.