Skip to content

Commit

Permalink
net: tcp: Remove pointless recv callback calls
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rlubos authored and carlescufi committed Dec 13, 2023
1 parent 6b00b53 commit 8cb4f09
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions subsys/net/ip/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8cb4f09

Please sign in to comment.