Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit 92de1a0

Browse files
committed
fix some problems
1 parent fdcdd4d commit 92de1a0

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/ESPAsyncTCP.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ bool AsyncClient::connect(IPAddress ip, uint16_t port){
116116
}
117117

118118
tcp_pcb* pcb = tcp_new();
119-
if (!pcb) //could not allocate pcb
119+
if (!pcb){ //could not allocate pcb
120120
return false;
121+
}
121122

122123
#if ASYNC_TCP_SSL_ENABLED
123124
_pcb_secure = secure;

src/SyncClient.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int SyncClient::connect(IPAddress ip, uint16_t port){
6868
#else
6969
if(_client->connect(ip, port)){
7070
#endif
71-
while(_client != NULL && !_client->connected() && _client->connecting())
71+
while(_client != NULL && !_client->connected() && !_client->disconnecting())
7272
delay(1);
7373
return connected();
7474
}
@@ -80,8 +80,9 @@ int SyncClient::connect(const char *host, uint16_t port, bool secure){
8080
#else
8181
int SyncClient::connect(const char *host, uint16_t port){
8282
#endif
83-
if(_client != NULL && connected())
83+
if(_client != NULL && connected()){
8484
return 0;
85+
}
8586
_client = new AsyncClient();
8687
_client->onConnect([](void *obj, AsyncClient *c){ ((SyncClient*)(obj))->_onConnect(c); }, this);
8788
_attachCallbacks_Disconnect();
@@ -90,7 +91,7 @@ int SyncClient::connect(const char *host, uint16_t port){
9091
#else
9192
if(_client->connect(host, port)){
9293
#endif
93-
while(_client != NULL && !_client->connected() && _client->connecting())
94+
while(_client != NULL && !_client->connected() && !_client->disconnecting())
9495
delay(1);
9596
return connected();
9697
}
@@ -179,14 +180,10 @@ void SyncClient::_onDisconnect(){
179180
_tx_buffer = NULL;
180181
delete b;
181182
}
182-
while(_rx_buffer != NULL){
183-
cbuf *b = _rx_buffer;
184-
_rx_buffer = b->next;
185-
delete b;
186-
}
187183
}
188184

189185
void SyncClient::_onConnect(AsyncClient *c){
186+
_client = c;
190187
if(_tx_buffer != NULL){
191188
cbuf *b = _tx_buffer;
192189
_tx_buffer = NULL;

0 commit comments

Comments
 (0)