Skip to content

Commit f736219

Browse files
committed
Ensure dispose is run in close if needed
If close is being run when the pcb is nulled, and we find an event on the queue, run dispose. This catches cases where fin or error is pending.
1 parent 97c6772 commit f736219

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/AsyncTCP.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static inline lwip_tcp_event_packet_t *_get_async_event() {
253253
}
254254
}
255255

256-
static void _remove_events_for_client(AsyncClient *client) {
256+
static size_t _remove_events_for_client(AsyncClient *client) {
257257
lwip_tcp_event_packet_t *removed_event_chain;
258258
{
259259
queue_mutex_guard guard;
@@ -269,6 +269,7 @@ static void _remove_events_for_client(AsyncClient *client) {
269269
removed_event_chain = t->next;
270270
_free_event(t);
271271
}
272+
return count;
272273
};
273274

274275
void AsyncTCP_detail::handle_async_event(lwip_tcp_event_packet_t *e) {
@@ -637,7 +638,9 @@ static err_t _tcp_close_api(struct tcpip_api_call_data *api_call_msg) {
637638
*msg->pcb = nullptr; // PCB is now the property of LwIP
638639
} else {
639640
// Ensure there is not an error event queued for this client
640-
_remove_events_for_client(msg->close);
641+
if (_remove_events_for_client(msg->close)) {
642+
msg->err = ERR_OK; // dispose needs to be run
643+
}
641644
}
642645
return msg->err;
643646
}

0 commit comments

Comments
 (0)