net: tcp: Only do ref when resending if we could send the packet

If the packet sending is slow then we must NOT increment the ref
count when re-sending it. This is unlikely but can happen if there
are lot of debug prints etc. extra activities that prevent the driver
to actually send the packet fast enough.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2017-08-15 21:46:36 +03:00 committed by Anas Nashif
commit cdec73d21e

View file

@ -185,7 +185,10 @@ static void tcp_retry_expired(struct k_timer *timer)
pkt = CONTAINER_OF(sys_slist_peek_head(&tcp->sent_list),
struct net_pkt, sent_list);
do_ref_if_needed(tcp, pkt);
if (net_pkt_sent(pkt)) {
do_ref_if_needed(tcp, pkt);
net_pkt_set_sent(pkt, false);
}
if (net_tcp_send_pkt(pkt) < 0 && !is_6lo_technology(pkt)) {
NET_DBG("[%p] pkt %p send failed", tcp, pkt);