net: tcp: Do buf ref when resending a segment

We need to check whether buf_sent was true when resending the TCP
segment, and do a buf ref if needed. If this is not done, the buf
will be unref after send, which will cause unpredictable results.

Change-Id: Ibd4490305de88ac6ffd04ec42bba196e57da5c10
Signed-off-by: june li <junelizh@foxmail.com>
This commit is contained in:
june li 2017-04-14 10:07:02 +08:00 committed by Jukka Rissanen
commit 504b273b85

View file

@ -831,7 +831,10 @@ void net_tcp_ack_received(struct net_context *ctx, uint32_t ack)
SYS_SLIST_FOR_EACH_CONTAINER(&ctx->tcp->sent_list, buf,
sent_list) {
net_nbuf_set_buf_sent(buf, false);
if (net_nbuf_buf_sent(buf)) {
do_ref_if_needed(buf);
net_nbuf_set_buf_sent(buf, false);
}
}
net_tcp_send_data(ctx);