Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't error when calling listen again on the same local endpoint. #841

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

MabezDev
Copy link
Contributor

Provided the local endpoint we are listening to is the same, it is safe to call listen multiple times. Fixes the doc comment for the function too.

This isn't much use for this in smoltcp, in embassy-net it's crucial when writing an acceptor loop. Without this, if you try and accept on a socket that's already listening you'll immediately get an error. The only way around this is to first abort the socket, but this means that incoming connections can actually get aborted between the abort() and the next accept(), as I have sadly experienced myself today 🥲.

@codecov
Copy link

codecov bot commented Sep 16, 2023

Codecov Report

Merging #841 (00cde4e) into main (28a5dd1) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #841   +/-   ##
=======================================
  Coverage   79.58%   79.58%           
=======================================
  Files          78       78           
  Lines       27809    27813    +4     
=======================================
+ Hits        22131    22135    +4     
  Misses       5678     5678           
Files Changed Coverage Δ
src/socket/tcp.rs 96.62% <100.00%> (+<0.01%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

src/socket/tcp.rs Outdated Show resolved Hide resolved
Provided the local endpoint we are listening to is the same, it is safe
to call `listen` multiple times.
@thvdveld
Copy link
Contributor

Thank you!

@thvdveld thvdveld added this pull request to the merge queue Sep 20, 2023
Merged via the queue into smoltcp-rs:main with commit 280c938 Sep 20, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants