@@ -235,7 +235,7 @@ err_t lwipClient::recv_callback(struct tcp_pcb* tpcb, struct pbuf* p, err_t err)
235
235
236
236
if (p == NULL ) {
237
237
// Remote host has closed the connection -> close from our side
238
- this ->stop ();
238
+ this ->close_pcb ();
239
239
240
240
return ERR_OK;
241
241
}
@@ -345,7 +345,7 @@ void lwipClient::flush() {
345
345
tcp_output (this ->tcp_info ->pcb );
346
346
}
347
347
348
- void lwipClient::stop () {
348
+ void lwipClient::close_pcb () {
349
349
if (this ->tcp_info ->pcb != nullptr ) {
350
350
tcp_recv (this ->tcp_info ->pcb , nullptr );
351
351
tcp_sent (this ->tcp_info ->pcb , nullptr );
@@ -360,12 +360,18 @@ void lwipClient::stop() {
360
360
361
361
// FIXME if err != ERR_OK retry, there may be memory issues, retry?
362
362
}
363
+ }
363
364
365
+ void lwipClient::stop () {
366
+ this ->close_pcb ();
364
367
// reset all the other variables in this class
365
368
366
- // if(tcp->p != nullptr) {
367
- // pbuf_free(tcp->p); // FIXME it happens that a pbuf, with ref == 0 is added for some reason
368
- // }
369
+ if (this ->tcp_info ->pbuf_head != nullptr ) {
370
+ pbuf_free (this ->tcp_info ->pbuf_head ); // FIXME it happens that a pbuf, with ref == 0 is added for some reason
371
+ this ->tcp_info ->pbuf_head = nullptr ;
372
+ }
373
+ this ->tcp_info ->pbuf_offset = 0 ;
374
+
369
375
if (this ->tcp_info ->server != nullptr ) {
370
376
// need to first make the server point to nullptr, then remove the client, can cause infinite recursion
371
377
auto server = this ->tcp_info ->server ;
0 commit comments