net: tcp: Release buf after failing to send

After failing to send the buf we need to release it.
This is not done for Bluetooth or IEEE 802.15.4 links which
create a copy of the sent buf and the failure case is already
checked by net_tcp_send_buf().

Change-Id: Ia556376b58ad74f68accb64eb2221a78d59dc2ec
Signed-off-by: june li <junelizh@foxmail.com>
This commit is contained in:
june li 2017-04-08 13:45:41 +08:00 committed by Jukka Rissanen
commit 961d7fc8f4

View file

@ -154,7 +154,9 @@ static void tcp_retry_expired(struct k_timer *timer)
struct net_buf, sent_list);
do_ref_if_needed(buf);
net_tcp_send_buf(buf);
if (net_tcp_send_buf(buf) < 0 && !is_6lo_technology(buf)) {
net_nbuf_unref(buf);
}
} else if (IS_ENABLED(CONFIG_NET_TCP_TIME_WAIT)) {
if (tcp->fin_sent && tcp->fin_rcvd) {
net_context_unref(tcp->context);
@ -764,7 +766,10 @@ int net_tcp_send_data(struct net_context *context)
*/
SYS_SLIST_FOR_EACH_CONTAINER(&context->tcp->sent_list, buf, sent_list) {
if (!net_nbuf_buf_sent(buf)) {
net_tcp_send_buf(buf);
if (net_tcp_send_buf(buf) < 0 &&
!is_6lo_technology(buf)) {
net_nbuf_unref(buf);
}
}
}