net: tcp: Remove pointless recv callback calls

Calling the registered receive callback when releasing TCP context
doesn't make sense, as at that point the application should've already
closed the associated socket (that's one of the conditions for the
context to be released). Therefore, remove the pointless receive
callback call, while keeping the loop to unref any leftover data packets
(although again, I don' think there should be any packets left at that
point, as they're all consumed in tcp_in()).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2023-12-11 16:54:54 +01:00 committed by Carles Cufí
parent 6b00b537aa
commit 8cb4f09a28

View file

@ -714,15 +714,11 @@ static void tcp_conn_release(struct k_work *work)
k_mutex_lock(&tcp_lock, K_FOREVER);
/* If there is any pending data, pass that to application */
/* Application is no longer there, unref any remaining packets on the
* fifo (although there shouldn't be any at this point.)
*/
while ((pkt = k_fifo_get(&conn->recv_data, K_NO_WAIT)) != NULL) {
if (net_context_packet_received(
(struct net_conn *)conn->context->conn_handler,
pkt, NULL, NULL, conn->recv_user_data) ==
NET_DROP) {
/* Application is no longer there, unref the pkt */
tcp_pkt_unref(pkt);
}
tcp_pkt_unref(pkt);
}
k_mutex_lock(&conn->lock, K_FOREVER);