Skip to content

Commit

Permalink
Fix a crash due to abort() called from TCP error callback (esp8266#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed Sep 28, 2015
1 parent d31aa5a commit 2366e60
Showing 1 changed file with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
/*
ClientContext.h - TCP connection handling on top of lwIP
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
This file is part of the esp8266 core for Arduino environment.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
Expand Down Expand Up @@ -39,7 +39,7 @@ class ClientContext {
tcp_sent(pcb, &_s_sent);
tcp_err(pcb, &_s_error);
}

err_t abort(){
if(_pcb) {
DEBUGV(":abort\r\n");
Expand All @@ -52,7 +52,7 @@ class ClientContext {
}
return ERR_ABRT;
}

err_t close(){
err_t err = ERR_OK;
if(_pcb) {
Expand All @@ -71,7 +71,7 @@ class ClientContext {
}
return err;
}

~ClientContext() {
}

Expand Down Expand Up @@ -101,18 +101,18 @@ class ClientContext {
}
}
}

void setNoDelay(bool nodelay){
if(!_pcb) return;
if(nodelay) tcp_nagle_disable(_pcb);
else tcp_nagle_enable(_pcb);
}

bool getNoDelay(){
if(!_pcb) return false;
return tcp_nagle_disabled(_pcb);
}

uint32_t getRemoteAddress() {
if(!_pcb) return 0;

Expand Down Expand Up @@ -277,16 +277,11 @@ class ClientContext {

void _error(err_t err) {
DEBUGV(":er %d %d %d\r\n", err, _size_sent, _send_waiting);
if (err != ERR_ABRT) {
abort();
}
else {
tcp_arg(_pcb, NULL);
tcp_sent(_pcb, NULL);
tcp_recv(_pcb, NULL);
tcp_err(_pcb, NULL);
_pcb = NULL;
}
tcp_arg(_pcb, NULL);
tcp_sent(_pcb, NULL);
tcp_recv(_pcb, NULL);
tcp_err(_pcb, NULL);
_pcb = NULL;
if(_size_sent && _send_waiting) {
esp_schedule();
}
Expand Down

0 comments on commit 2366e60

Please sign in to comment.