Note lwip_socket_dbg_get_socket wraps tryget_socket_unconn_nouse

This commit is contained in:
J. Nick Koston
2026-02-23 22:01:36 -06:00
parent cba004e2d1
commit 04af37e514
+6 -4
View File
@@ -127,10 +127,12 @@ static void esphome_socket_event_callback(struct netconn *conn, enum netconn_evt
void esphome_lwip_fast_select_init(void) { s_main_loop_task = xTaskGetCurrentTaskHandle(); }
// lwip_socket_dbg_get_socket() is a direct array lookup without the refcount that
// get_socket()/done_socket() uses. This is safe because the caller owns the socket
// lifetime: both has_data() and socket close happen on the main loop thread, so
// the sockets[] entry cannot be freed while we read it.
// lwip_socket_dbg_get_socket() is a thin wrapper around the static
// tryget_socket_unconn_nouse() — a direct array lookup without the refcount
// that get_socket()/done_socket() uses. This is safe because the caller owns
// the socket lifetime: both has_data() and socket close happen on the main
// loop thread, so the sockets[] entry cannot be freed while we read it.
// If lwip_socket_dbg_get_socket() were ever removed, we could fall back to lwip_select().
// Returns the sock only if both the sock and its netconn are valid, NULL otherwise.
static inline struct lwip_sock *get_sock(int fd) {
struct lwip_sock *sock = lwip_socket_dbg_get_socket(fd);