@@ -223,6 +223,8 @@ AsyncClient::AsyncClient(tcp_pcb* pcb):
223
223
}
224
224
225
225
AsyncClient::~AsyncClient (){
226
+ ASYNC_TCP_DEBUG (" ~AsyncClient[%u]:%s\n " , getConnectionId (), ((NULL == _pcb) ? " NULL == pcb" : " " ));
227
+ _close_called = true ;
226
228
if (_pcb)
227
229
_close ();
228
230
@@ -344,6 +346,8 @@ void AsyncClient::abort(){
344
346
// of a 2nd call to tcp_abort().
345
347
// 6) Callbacks to _recv() or _connected() with err set, will result in _pcb
346
348
// set to NULL. Thus, preventing possible calls later to tcp_abort().
349
+ ASYNC_TCP_DEBUG (" ~AsyncClient[%u]\n " , getConnectionId ());
350
+ _close_called = true ;
347
351
if (_pcb) {
348
352
tcp_abort (_pcb);
349
353
_pcb = NULL ;
@@ -353,6 +357,8 @@ void AsyncClient::abort(){
353
357
}
354
358
355
359
void AsyncClient::close (bool now){
360
+ ASYNC_TCP_DEBUG (" close[%u](%d):%s\n " , getConnectionId (), now, ((NULL == _pcb) ? " NULL == pcb" : " " ));
361
+ _close_called = true ;
356
362
if (_pcb)
357
363
tcp_recved (_pcb, _rx_ack_len);
358
364
if (now)
@@ -362,10 +368,14 @@ void AsyncClient::close(bool now){
362
368
}
363
369
364
370
void AsyncClient::stop () {
371
+ ASYNC_TCP_DEBUG (" stop[%u]:%s\n " , getConnectionId ());
372
+ _close_called = true ;
365
373
close (false );
366
374
}
367
375
368
376
bool AsyncClient::free (){
377
+ ASYNC_TCP_DEBUG (" free[%u]:%s\n " , getConnectionId ());
378
+ _close_called = true ;
369
379
if (!_pcb)
370
380
return true ;
371
381
if (_pcb->state == 0 || _pcb->state > 4 )
@@ -493,6 +503,7 @@ void AsyncClient::_connected(std::shared_ptr<ACErrorTracker>& errorTracker, void
493
503
}
494
504
495
505
void AsyncClient::_close (){
506
+ ASYNC_TCP_DEBUG (" _close[%u]:%s\n " , getConnectionId (), ((NULL == _pcb) ? " NULL == pcb" : " " ));
496
507
if (_pcb) {
497
508
#if ASYNC_TCP_SSL_ENABLED
498
509
if (_pcb_secure){
@@ -526,9 +537,9 @@ void AsyncClient::_error(err_t err) {
526
537
// made to set to NULL other callbacks.
527
538
_pcb = NULL ;
528
539
}
529
- if (_error_cb)
540
+ if (_error_cb && !_close_called )
530
541
_error_cb (_error_cb_arg, this , err);
531
- if (_discard_cb)
542
+ if (_discard_cb && !_close_called )
532
543
_discard_cb (_discard_cb_arg, this );
533
544
}
534
545
0 commit comments