Page 1 of 1

mDNS component's real time safety

Posted: Wed Jun 20, 2018 11:47 am
by PeterR
Hi,
I am have an IoT application to develop on the ESP32. The device will advertise using mDNS, host a webserver etc etc.
There is an mDNS component in the ESP library which would be awesome to use.
I am puzzled though as the ESP component uses both a FreeRTOS thread and the LwIP raw UDP API (pbufs etc).

I had understood that the LwIP raw api was not reentrant. Perhaps the example works because only the mDNS component uses LwIP?
Is the mDNS component going to work when I add other tasks; webserver, MQTT etc?

Has anyone used the mDNS component with other tasks and IP activity?

Re: mDNS component's real time safety

Posted: Wed Jun 20, 2018 4:17 pm
by kolban
Howdy and welcome to the forum. I haven't looked inside the mDNS component's implementation but my belief is that the internals of such a component are free to use whichever technology/implementations that makes sense to them as long as the result satisfies the contract of usage. I haven't seen anywhere a statement that using the mDNS component precludes using the other networking APIs such as WiFi and sockets.

There appears to be a sample of using the mDNS component found here:

https://github.com/espressif/esp-idf/bl ... ple_main.c

Re: mDNS component's real time safety

Posted: Fri Jun 22, 2018 1:34 pm
by PeterR
Thanks.
Looking into this deeper and there are semaphores controlling Ethernet buffer access within emac_main.c
I am not sure though; although pbuf() allocation seems to be controlled pbuf chaining does not appear to be controlled.

Anyone able to confirm and/or provide reference (I know the LwIP reference that raw api is not thread safe)?

Re: mDNS component's real time safety

Posted: Sun Jun 24, 2018 12:16 pm
by ESP_igrr
mDNS indeed was initially written on top of non thread safe raw API. Thread safety was implemented in https://github.com/espressif/esp-idf/pull/733 later.

Re: mDNS component's real time safety

Posted: Sun Jun 24, 2018 3:13 pm
by WiFive
mdns has been rewritten since that commit and the current init and deinit are done in API calls but write is not.

Re: mDNS component's real time safety

Posted: Thu Jun 28, 2018 11:07 am
by PeterR
Cool, that really helps a lot. I did not spot tcpip_api_call() in the API documentation (is it documented?).
Easy enough now to modify this and other thread unsafe examples.
Weird that they undid the RT safety on the write though.