Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Nanostack: release connect_semaphore only when it is pending #10462
The rationale behind this PR is the following. It often happens that a Thread device gets local connectivity before the global connectivity. In such case the network handler is called twice and each time releases the _connect_semaphore. If the device disconnects and then connects again, the previously released (incremented) semaphore will be available for immediate decrementation and the connect will not really block.
I also noticed some detailed guidelines about when to consider a Thread device connected, but those are Thread-specific, and should not be implemented in general Nanostack network_handler. It made me wonder however if the semaphore should perhaps be released in the lower layer, so a Thread device unblocks at a different point than a LOWPAN device, perhaps?
@0xc0170 , does the CI for PRs run any Nanostack tests? I assumed not and hacked our CI to run this commit for me on multiple platforms to check that nothing gets broken, but I wonder if I should have relied on CI?
Pull request type
kjbracey-arm left a comment
Good example of why I hate semaphores so much. The counting is almost always a hindrance, not a help.
I'd be inclined to tear it all up and use a