Skip to content

Fix AVDTP endpoint resource leak by clearing the in_use flag on strea…#923

Open
laozhuxinlu wants to merge 1 commit into
google:mainfrom
laozhuxinlu:avdtp_abort_issue_fix
Open

Fix AVDTP endpoint resource leak by clearing the in_use flag on strea…#923
laozhuxinlu wants to merge 1 commit into
google:mainfrom
laozhuxinlu:avdtp_abort_issue_fix

Conversation

@laozhuxinlu
Copy link
Copy Markdown

Fix an AVDTP endpoint resource leak where the in_use flag was 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.

Comment thread bumble/avdtp.py

if self.rtp_channel is None:
# No channel to release, we're done
self.local_endpoint.in_use = 0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants