2828
2929#include "sys.h"
3030
31- #define REGISTER_PORT_DRIVER (NAME , INIT_CB , CREATE_CB ) \
31+ #define REGISTER_PORT_DRIVER (NAME , INIT_CB , DESTROY_CB , CREATE_CB ) \
3232 struct PortDriverDef NAME##_port_driver_def = { \
3333 .port_driver_name = #NAME, \
3434 .port_driver_init_cb = INIT_CB, \
35+ .port_driver_destroy_cb = DESTROY_CB, \
3536 .port_driver_create_port_cb = CREATE_CB \
3637 }; \
3738 \
4546 port_driver_list = &NAME##_port_driver_def_list_item; \
4647 }
4748
48- #define REGISTER_NIF_COLLECTION (NAME , INIT_CB , RESOLVE_NIF_CB ) \
49+ #define REGISTER_NIF_COLLECTION (NAME , INIT_CB , DESTROY_CB , RESOLVE_NIF_CB ) \
4950 struct NifCollectionDef NAME##_nif_collection_def = { \
5051 .nif_collection_init_cb = INIT_CB, \
52+ .nif_collection_destroy_cb = DESTROY_CB, \
5153 .nif_collection_resove_nif_cb = RESOLVE_NIF_CB \
5254 }; \
5355 \
@@ -74,17 +76,21 @@ struct EventListener
7476
7577struct ESP32PlatformData
7678{
79+ // socket_driver
80+ EventListener * socket_listener ;
7781 struct SyncList sockets ;
7882 struct ListHead ready_connections ;
7983};
8084
8185typedef void (* port_driver_init_t )(GlobalContext * global );
86+ typedef void (* port_driver_destroy_t )(GlobalContext * global );
8287typedef Context * (* port_driver_create_port_t )(GlobalContext * global , term opts );
8388
8489struct PortDriverDef
8590{
8691 const char * port_driver_name ;
8792 const port_driver_init_t port_driver_init_cb ;
93+ const port_driver_destroy_t port_driver_destroy_cb ;
8894 const port_driver_create_port_t port_driver_create_port_cb ;
8995};
9096
@@ -95,11 +101,13 @@ struct PortDriverDefListItem
95101};
96102
97103typedef void (* nif_collection_init_t )(GlobalContext * global );
104+ typedef void (* nif_collection_destroy_t )(GlobalContext * global );
98105typedef const struct Nif * (* nif_collection_resolve_nif_t )(const char * name );
99106
100107struct NifCollectionDef
101108{
102109 const nif_collection_init_t nif_collection_init_cb ;
110+ const nif_collection_destroy_t nif_collection_destroy_cb ;
103111 const nif_collection_resolve_nif_t nif_collection_resove_nif_cb ;
104112};
105113
@@ -121,7 +129,9 @@ void sys_event_listener_init(EventListener *listener, void *sender, event_handle
121129void socket_init (Context * ctx , term opts );
122130
123131void port_driver_init_all (GlobalContext * global );
132+ void port_driver_destroy_all (GlobalContext * global );
124133void nif_collection_init_all (GlobalContext * global );
134+ void nif_collection_destroy_all (GlobalContext * global );
125135const struct Nif * nif_collection_resolve_nif (const char * name );
126136
127137#endif
0 commit comments