which will lead to memory leak
Closes https://github.com/espressif/esp-idf/issues/784
return conn;
}
+static inline bool is_created_by_socket(struct netconn *conn)
+{
+#if LWIP_SOCKET
+ if (conn && (conn->socket != -1)) {
+ return true;
+ }
+#endif
+ return false;
+}
/**
* Close a netconn 'connection' and free its resources.
* UDP and RAW connection are completely closed, TCP pcbs might still be in a waitstate
return err;
}
-#if !ESP_THREAD_SAFE
+#if ESP_THREAD_SAFE
+ if (is_created_by_socket(conn) == false) {
+ LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("netconn_delete - free conn\n"));
+ netconn_free(conn);
+ }
+#else
LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("netconn_delete - free conn\n"));
netconn_free(conn);
#endif