component: lwip
1. add lock version print for lwip (workaround) 2. add debug info into sys_arch.c to debug xQueueReceive issue
This commit is contained in:
parent
ef0cd1cde3
commit
52953851f4
|
@ -1539,7 +1539,7 @@ again:
|
|||
break;
|
||||
case(DHCP_OPTION_DNS_SERVER):
|
||||
/* special case: there might be more than one server */
|
||||
LWIP_ERROR("len % 4 == 0", len % 4 == 0, return ERR_VAL;);
|
||||
//LWIP_ERROR("len % 4 == 0", len % 4 == 0, return ERR_VAL;);
|
||||
/* limit number of DNS servers */
|
||||
decode_len = LWIP_MIN(len, 4 * DNS_MAX_SERVERS);
|
||||
LWIP_ERROR("len >= decode_len", len >= decode_len, return ERR_VAL;);
|
||||
|
@ -1595,7 +1595,7 @@ decode_next:
|
|||
pbuf_copy_partial(q, &value, copy_len, val_offset);
|
||||
if (decode_len > 4) {
|
||||
/* decode more than one u32_t */
|
||||
LWIP_ERROR("decode_len % 4 == 0", decode_len % 4 == 0, return ERR_VAL;);
|
||||
//LWIP_ERROR("decode_len % 4 == 0", decode_len % 4 == 0, return ERR_VAL;);
|
||||
dhcp_got_option(dhcp, decode_idx);
|
||||
dhcp_set_option_value(dhcp, decode_idx, htonl(value));
|
||||
decode_len -= 4;
|
||||
|
|
|
@ -97,6 +97,7 @@
|
|||
/** print debug message only if debug message type is enabled...
|
||||
* AND is of correct type AND is at least LWIP_DBG_LEVEL
|
||||
*/
|
||||
//#define LWIP_DEBUGF(debug, message) do {
|
||||
#define LWIP_DEBUGF(debug, message) do { \
|
||||
if ( \
|
||||
((debug) & LWIP_DBG_ON) && \
|
||||
|
|
|
@ -65,7 +65,21 @@ typedef int sys_prot_t;
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
|
||||
//#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
|
||||
#if 1//def ESP32_WORKAROUND
|
||||
extern SemaphoreHandle_t stdio_mutex_tx;
|
||||
#define LWIP_PLATFORM_DIAG(message)\
|
||||
do{\
|
||||
if (!stdio_mutex_tx) {\
|
||||
stdio_mutex_tx = xSemaphoreCreateMutex();\
|
||||
}\
|
||||
\
|
||||
xSemaphoreTake(stdio_mutex_tx, portMAX_DELAY);\
|
||||
ets_printf message;\
|
||||
xSemaphoreGive(stdio_mutex_tx);\
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#define LWIP_PLATFORM_ASSERT(x) do {printf(x); sys_arch_assert(__FILE__, __LINE__);} while(0)
|
||||
|
||||
//#define LWIP_DEBUG
|
||||
|
|
|
@ -506,9 +506,9 @@ extern unsigned char misc_prof_get_tcp_snd_buf(void);
|
|||
* DHCP_DEBUG: Enable debugging in dhcp.c.
|
||||
*/
|
||||
#define DHCP_DEBUG LWIP_DBG_OFF
|
||||
//#define LWIP_DEBUG 1
|
||||
//#define TCP_DEBUG LWIP_DBG_ON
|
||||
#define THREAD_SAFE_DEBUG LWIP_DBG_OFF
|
||||
#define LWIP_DEBUG 1
|
||||
#define TCP_DEBUG LWIP_DBG_ON
|
||||
#define THREAD_SAFE_DEBUG LWIP_DBG_ON
|
||||
#define LWIP_THREAD_SAFE 1
|
||||
|
||||
#define CHECKSUM_CHECK_UDP 0
|
||||
|
|
|
@ -292,8 +292,10 @@ sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
|
|||
}
|
||||
} else { // block forever for a message.
|
||||
while (1){
|
||||
|
||||
if (pdTRUE == xQueueReceive((*mbox)->os_mbox, &(*msg), portMAX_DELAY)){
|
||||
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_arch_mbox_fetch: fetch mbox=%p os_mbox=%p lock=%p\n", mbox, (*mbox)->os_mbox, (*mbox)->lock));
|
||||
//if (pdTRUE == xQueueReceive((*mbox)->os_mbox, &(*msg), portMAX_DELAY)){
|
||||
if (pdTRUE == xQueueReceive((*mbox)->os_mbox, &(*msg), 3000/portTICK_RATE_MS)){ //ESP32_WORKAROUND
|
||||
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_arch_mbox_fetch:mbox rx msg=%p\n", (*msg)));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -348,13 +350,15 @@ sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
|
|||
void
|
||||
sys_mbox_free(sys_mbox_t *mbox)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
#define MAX_POLL_CNT 100
|
||||
#define PER_POLL_DELAY 20
|
||||
uint16_t count = 0;
|
||||
bool post_null = true;
|
||||
|
||||
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mbox_free: set alive false\n"));
|
||||
(*mbox)->alive = false;
|
||||
|
||||
while ( count++ < 10 ){
|
||||
while ( count++ < MAX_POLL_CNT ){ //ESP32_WORKAROUND
|
||||
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mbox_free:try lock=%d\n", count));
|
||||
if (!sys_mutex_trylock( &(*mbox)->lock )){
|
||||
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mbox_free:get lock ok %d\n", count));
|
||||
|
@ -372,14 +376,15 @@ sys_mbox_free(sys_mbox_t *mbox)
|
|||
}
|
||||
}
|
||||
|
||||
if (count == 10){
|
||||
if (count == (MAX_POLL_CNT-1)){
|
||||
printf("WARNING: mbox %p had a consumer who never unblocked. Leaking!\n", (*mbox)->os_mbox);
|
||||
}
|
||||
sys_delay_ms(20);
|
||||
sys_delay_ms(PER_POLL_DELAY);
|
||||
}
|
||||
|
||||
LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("sys_mbox_free:free mbox\n"));
|
||||
|
||||
#if 0 //ESP32_WORKAROUND
|
||||
if (uxQueueMessagesWaiting((*mbox)->os_mbox)) {
|
||||
xQueueReset((*mbox)->os_mbox);
|
||||
/* Line for breakpoint. Should never break here! */
|
||||
|
@ -390,6 +395,7 @@ sys_mbox_free(sys_mbox_t *mbox)
|
|||
sys_mutex_free(&(*mbox)->lock);
|
||||
free(*mbox);
|
||||
*mbox = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue