aiortc / aioice

asyncio-based Interactive Connectivity Establishment (RFC 5245)
BSD 3-Clause "New" or "Revised" License
105 stars 51 forks source link

Multiple early checks from same source results in unhandled tasks #59

Closed ddiaz-yx closed 1 year ago

ddiaz-yx commented 2 years ago

Tested on version 0.7.6.

If multiple checks from a remote peer arrive before checklist from Connection class is set, then all of them are appended to the earlychecks list and then acted upon on the connect method:

        # handle early checks
        for early_check in self._early_checks:
            self.check_incoming(*early_check)
        self._early_checks = []

Then the _checkincoming method creates a task for each early check and overwrites the handle for the associated pair:

            pair.handle = asyncio.ensure_future(self.check_start(pair))

Since the handle for some tasks is lost, they become unreachable and are not canceled after completion.

It is even possible to see mutiple times a transition State.IN_PROGRESS -> State.IN_PROGRESS for some candidate pairs.

jlaine commented 2 years ago

Sounds like a valid point, would you be ready to contribute a PR?

eerimoq commented 1 year ago

I noticed this as well. Any updates @ddiaz-yx ?

eerimoq commented 1 year ago

I created a PR that do not start a check if a check is already ongoing: https://github.com/aiortc/aioice/pull/68

jlaine commented 1 year ago

Fixed in https://github.com/aiortc/aioice/commit/54a575139b398a5d168512bc8c26b13d868068ce, thanks @eerimoq