bugfix for assert when tcp send data

This commit is contained in:
xueyunfei
2021-03-24 17:46:29 +08:00
parent 9ba867277a
commit 2c9c531f0a
3 changed files with 41 additions and 0 deletions
+30
View File
@@ -794,6 +794,11 @@ netconn_alloc(enum netconn_type t, netconn_callback callback)
conn->callback = callback;
#if LWIP_TCP
conn->current_msg = NULL;
#if ESP_THREAD_PROTECTION
conn->write_protection = false;
#endif /* ESP_THREAD_PROTECTION */
#endif /* LWIP_TCP */
#if LWIP_SO_SNDTIMEO
conn->send_timeout = 0;
@@ -1719,6 +1724,18 @@ lwip_netconn_do_writemore(struct netconn *conn WRITE_DELAYED_PARAM)
u8_t apiflags;
u8_t write_more;
#if ESP_THREAD_PROTECTION
if(conn->write_protection == true) {
return ERR_OK;
}
TCP_WRITE_LOCK(conn);
if (conn->state != NETCONN_WRITE) {
TCP_WRITE_UNLOCK(conn);
return ERR_OK;
}
#endif /* ESP_THREAD_PROTECTION */
LWIP_ASSERT("conn != NULL", conn != NULL);
LWIP_ASSERT("conn->state == NETCONN_WRITE", (conn->state == NETCONN_WRITE));
LWIP_ASSERT("conn->current_msg != NULL", conn->current_msg != NULL);
@@ -1862,14 +1879,27 @@ err_mem:
if (delayed)
#endif
{
#if ESP_THREAD_PROTECTION
TCP_WRITE_UNLOCK(conn);
sys_sem_signal(op_completed_sem);
return ERR_OK;
#else
sys_sem_signal(op_completed_sem);
#endif /* ESP_THREAD_PROTECTION */
}
}
#if LWIP_TCPIP_CORE_LOCKING
else {
#if ESP_THREAD_PROTECTION
TCP_WRITE_UNLOCK(conn);
#endif /*ESP_THREAD_PROTECTION */
return ERR_MEM;
}
#endif
#if ESP_THREAD_PROTECTION
TCP_WRITE_UNLOCK(conn);
#endif /*ESP_THREAD_PROTECTION */
return ERR_OK;
}
#endif /* LWIP_TCP */
+10
View File
@@ -240,6 +240,9 @@ struct netconn {
/** mbox where new connections are stored until processed
by the application thread */
sys_mbox_t acceptmbox;
#if ESP_THREAD_PROTECTION
bool write_protection;
#endif /* ESP_THREAD_PROTECTION */
#endif /* LWIP_TCP */
#if LWIP_NETCONN_FULLDUPLEX
/** number of threads waiting on an mbox. This is required to unblock
@@ -422,6 +425,13 @@ void netconn_thread_cleanup(void);
#define netconn_thread_cleanup()
#endif /* LWIP_NETCONN_SEM_PER_THREAD */
#if ESP_THREAD_PROTECTION
#define TCP_WRITE_LOCK(conn) ((conn)->write_protection = (true))
#define TCP_WRITE_UNLOCK(conn) ((conn)->write_protection = (false))
#endif /* ESP_THREAD_PROTECTION */
#ifdef __cplusplus
}
#endif
+1
View File
@@ -103,6 +103,7 @@
#define ESP_LWIP_LOCK 1
#define TCP_OOSEQ_DEBUG LWIP_DBG_ON
#define ESP_DHCP_DEBUG 1
#define ESP_THREAD_PROTECTION 0
#ifdef IP_NAPT
#define IP_NAPT_MAX 16