File tree Expand file tree Collapse file tree
espressif/common-hal/mdns
raspberrypi/common-hal/mdns Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333
3434#include "components/mdns/include/mdns.h"
3535
36- STATIC bool inited = false;
36+ // Track whether the underlying IDF mdns has been started so that we only
37+ // create a single inited MDNS object to CircuitPython. (After deinit, another
38+ // could be created.)
39+ STATIC bool mdns_started = false;
3740
3841void mdns_server_construct (mdns_server_obj_t * self , bool workflow ) {
39- if (inited ) {
42+ if (mdns_started ) {
43+ // Mark this object as deinited because another is already using MDNS.
4044 self -> inited = false;
4145 return ;
4246 }
4347 mdns_init ();
48+ mdns_started = true;
4449
4550 uint8_t mac [6 ];
4651 esp_netif_get_mac (common_hal_wifi_radio_obj .netif , mac );
@@ -81,7 +86,7 @@ void common_hal_mdns_server_deinit(mdns_server_obj_t *self) {
8186 return ;
8287 }
8388 self -> inited = false;
84- inited = false;
89+ mdns_started = false;
8590 mdns_free ();
8691}
8792
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ typedef struct {
3232 mp_obj_base_t base ;
3333 const char * hostname ;
3434 const char * instance_name ;
35- // "cpy-" " XXXXXX" "\0"
36- char default_hostname [ 4 + 6 + 1 ];
35+ char default_hostname [ sizeof ( "cpy-XXXXXX" )];
36+ // Track if this object owns access to the underlying MDNS service.
3737 bool inited ;
3838} mdns_server_obj_t ;
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ STATIC bool object_inited = false;
4848
4949void mdns_server_construct (mdns_server_obj_t * self , bool workflow ) {
5050 if (object_inited ) {
51+ // Mark the object as deinit since another is already using MDNS.
5152 self -> inited = false;
5253 return ;
5354 }
Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ typedef struct {
3434 mp_obj_base_t base ;
3535 const char * hostname ;
3636 const char * instance_name ;
37- // "cpy-" "XXXXXX" "\0"
38- char default_hostname [4 + 6 + 1 ];
37+ char default_hostname [sizeof ("cpy-XXXXXX" )];
3938 const char * service_type [MDNS_MAX_SERVICES ];
39+ // Track if this object owns access to the underlying MDNS service.
4040 bool inited ;
4141} mdns_server_obj_t ;
You can’t perform that action at this time.
0 commit comments