mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 12:10:13 +01:00
esp32/network_ppp: Use non-thread-safe API inside status callback.
The status callback runs on the lwIP tcpip_thread, and thus must use the non-thread-safe API because the thread-safe API would cause a deadlock. Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
This commit is contained in:
committed by
Damien George
parent
361c615f3e
commit
adcfdf625b
@@ -62,8 +62,6 @@ typedef struct _network_ppp_obj_t {
|
|||||||
|
|
||||||
const mp_obj_type_t mp_network_ppp_lwip_type;
|
const mp_obj_type_t mp_network_ppp_lwip_type;
|
||||||
|
|
||||||
static mp_obj_t network_ppp___del__(mp_obj_t self_in);
|
|
||||||
|
|
||||||
static void network_ppp_stream_uart_irq_disable(network_ppp_obj_t *self) {
|
static void network_ppp_stream_uart_irq_disable(network_ppp_obj_t *self) {
|
||||||
if (self->stream == mp_const_none) {
|
if (self->stream == mp_const_none) {
|
||||||
return;
|
return;
|
||||||
@@ -88,8 +86,12 @@ static void network_ppp_status_cb(ppp_pcb *pcb, int err_code, void *ctx) {
|
|||||||
// only need to free the PPP PCB, not close it.
|
// only need to free the PPP PCB, not close it.
|
||||||
self->state = STATE_ACTIVE;
|
self->state = STATE_ACTIVE;
|
||||||
}
|
}
|
||||||
|
network_ppp_stream_uart_irq_disable(self);
|
||||||
// Clean up the PPP PCB.
|
// Clean up the PPP PCB.
|
||||||
network_ppp___del__(MP_OBJ_FROM_PTR(self));
|
if (ppp_free(pcb) == ERR_OK) {
|
||||||
|
self->state = STATE_INACTIVE;
|
||||||
|
self->pcb = NULL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
self->state = STATE_ERROR;
|
self->state = STATE_ERROR;
|
||||||
|
|||||||
@@ -68,8 +68,6 @@ typedef struct _network_ppp_obj_t {
|
|||||||
|
|
||||||
const mp_obj_type_t esp_network_ppp_lwip_type;
|
const mp_obj_type_t esp_network_ppp_lwip_type;
|
||||||
|
|
||||||
static mp_obj_t network_ppp___del__(mp_obj_t self_in);
|
|
||||||
|
|
||||||
static void network_ppp_stream_uart_irq_disable(network_ppp_obj_t *self) {
|
static void network_ppp_stream_uart_irq_disable(network_ppp_obj_t *self) {
|
||||||
if (self->stream == mp_const_none) {
|
if (self->stream == mp_const_none) {
|
||||||
return;
|
return;
|
||||||
@@ -94,8 +92,15 @@ static void network_ppp_status_cb(ppp_pcb *pcb, int err_code, void *ctx) {
|
|||||||
// only need to free the PPP PCB, not close it.
|
// only need to free the PPP PCB, not close it.
|
||||||
self->state = STATE_ACTIVE;
|
self->state = STATE_ACTIVE;
|
||||||
}
|
}
|
||||||
|
network_ppp_stream_uart_irq_disable(self);
|
||||||
// Clean up the PPP PCB.
|
// Clean up the PPP PCB.
|
||||||
network_ppp___del__(MP_OBJ_FROM_PTR(self));
|
// Note: Because we use pppapi_close instead of ppp_close, this
|
||||||
|
// callback will run on the lwIP tcpip_thread, thus to prevent a
|
||||||
|
// deadlock we must use the non-threadsafe function here.
|
||||||
|
if (ppp_free(pcb) == ERR_OK) {
|
||||||
|
self->state = STATE_INACTIVE;
|
||||||
|
self->pcb = NULL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
self->state = STATE_ERROR;
|
self->state = STATE_ERROR;
|
||||||
|
|||||||
Reference in New Issue
Block a user