Skip to content

Commit d27a12a

Browse files
Bmooijme-no-dev
authored andcommitted
Fix assertion errors (me-no-dev#72)
* Fix assertion errors * Add state check * replace tabs with spaces
1 parent 6a54164 commit d27a12a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/AsyncTCP.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -847,10 +847,12 @@ int8_t AsyncClient::_connected(void* pcb, int8_t err){
847847
void AsyncClient::_error(int8_t err) {
848848
if(_pcb){
849849
tcp_arg(_pcb, NULL);
850-
tcp_sent(_pcb, NULL);
851-
tcp_recv(_pcb, NULL);
852-
tcp_err(_pcb, NULL);
853-
tcp_poll(_pcb, NULL, 0);
850+
if(_pcb->state == LISTEN) {
851+
tcp_sent(_pcb, NULL);
852+
tcp_recv(_pcb, NULL);
853+
tcp_err(_pcb, NULL);
854+
tcp_poll(_pcb, NULL, 0);
855+
}
854856
_pcb = NULL;
855857
}
856858
if(_error_cb) {
@@ -868,10 +870,12 @@ int8_t AsyncClient::_lwip_fin(tcp_pcb* pcb, int8_t err) {
868870
return ERR_OK;
869871
}
870872
tcp_arg(_pcb, NULL);
871-
tcp_sent(_pcb, NULL);
872-
tcp_recv(_pcb, NULL);
873-
tcp_err(_pcb, NULL);
874-
tcp_poll(_pcb, NULL, 0);
873+
if(_pcb->state == LISTEN) {
874+
tcp_sent(_pcb, NULL);
875+
tcp_recv(_pcb, NULL);
876+
tcp_err(_pcb, NULL);
877+
tcp_poll(_pcb, NULL, 0);
878+
}
875879
if(tcp_close(_pcb) != ERR_OK) {
876880
tcp_abort(_pcb);
877881
}

0 commit comments

Comments
 (0)