Fix system failure when nc == NULL
@@ -182,26 +182,18 @@ netconn_evt(esp_evt_t* evt) {
pbuf = esp_evt_conn_recv_get_buff(evt); /* Get received buff */
esp_conn_recved(conn, pbuf); /* Notify stack about received data */
- nc->rcv_packets++; /* Increase number of received packets */
- /*
- * First increase reference number to prevent
- * other thread to process the incoming packet
- * and free it while we still need it here
- *
- * In case of problems writing packet to queue,
- * simply force free to decrease reference counter back to previous value
- */
esp_pbuf_ref(pbuf); /* Increase reference counter */
- if (!nc || !esp_sys_mbox_isvalid(&nc->mbox_receive)
+ if (nc == NULL || !esp_sys_mbox_isvalid(&nc->mbox_receive)
|| !esp_sys_mbox_putnow(&nc->mbox_receive, pbuf)) {
ESP_DEBUGF(ESP_CFG_DBG_NETCONN,
"[NETCONN] Ignoring more data for receive!\r\n");
esp_pbuf_free(pbuf); /* Free pbuf */
return espOKIGNOREMORE; /* Return OK to free the memory and ignore further data */
}
+ nc->rcv_packets++; /* Increase number of packets received */
ESP_DEBUGF(ESP_CFG_DBG_NETCONN | ESP_DBG_TYPE_TRACE,
- "[NETCONN] Written %d bytes to receive mbox\r\n",
+ "[NETCONN] Received pbuf contains %s bytes. Handle written to receive mbox\r\n",
(int)esp_pbuf_length(pbuf, 0));
break;
}
