Skip to content

Add mdns module #6175

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

Merged
merged 5 commits into from
Mar 21, 2022
Merged

Add mdns module #6175

merged 5 commits into from
Mar 21, 2022

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Mar 18, 2022

This allows for CircuitPython to resolve a .local domain and find
other devices with MDNS services.

First step for #6174

This allows for CircuitPython to resolve a .local domain and find
other devices with MDNS services.

First step for micropython#6174
@tannewt tannewt added this to the 7.3.0 milestone Mar 18, 2022
@tannewt tannewt requested a review from jepler March 18, 2022 01:19
@tannewt tannewt mentioned this pull request Mar 18, 2022
11 tasks
Copy link

@jepler jepler left a comment

Choose a reason for hiding this comment

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

There was one bit which looked suspicious; aside from that some comments that don't require any direct action on your part.

I appreciate you picking up this work, since I dropped the ball. I didn't do any testing, but I look forward to using it once I remember what project I was working on that called for it.

// Don't error if we're out of memory. Instead, truncate the tuple.
uint8_t added = 0;
while (next != NULL) {
mdns_remoteservice_obj_t *service = gc_alloc(sizeof(mdns_remoteservice_obj_t), true, false);
Copy link

Choose a reason for hiding this comment

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

Instead of true use GC_ALLOC_FLAG_HAS_FINALISER. Not using a finali(s/z)er here would be an easy mistake to make in a fresh implementation of Server; is there a way to move the allocation step to a place where it would be shared by all ports?

For that matter, why is RemoteService in the common-hal? If it's just a container for some data found during a search, then why not make it a kind of NamedTuple or similar, allowing it to live in shared-module.

Copy link
Member Author

Choose a reason for hiding this comment

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

The need for a finaliser is implementation specific in this case (therefore common-hal) because this implementation is a wrapper around the IDF allocated mdns_result_t. We could move it to shared-module and not need a finaliser but that'd require a copy of all the data into the MP heap even if it is never read.

Copy link

Choose a reason for hiding this comment

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

If this trade-off needs to be changed in the future, we can do it. My gut would have said that since the CircuitPython heap is generally larger than the IDF heap it might be better to preemptively move it, especially since then we can rely on the GC to free it after it's no longer possible to use it.

jepler
jepler previously approved these changes Mar 21, 2022
Copy link

@jepler jepler left a comment

Choose a reason for hiding this comment

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

Thanks!

@jepler
Copy link

jepler commented Mar 21, 2022

Looks like the doc build still needs some attention though. I couldn't get the github actions page to open (unicorn error) so I couldn't check into it further.

@tannewt
Copy link
Member Author

tannewt commented Mar 21, 2022

@jepler Finally passed CI. Just need one more 👍 from you.

Copy link

@jepler jepler left a comment

Choose a reason for hiding this comment

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

Yes!

@jepler jepler merged commit 4465adf into adafruit:main Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants