net: tcp: Fix the polling implementation with corrected window filling
The window full computation was corrected to use the send_total instead of the unacked_len. This conflicted with the new polling implementation due to the moment when these values are changed. Move taking the tx_sem outside of tcp_send_queued_data to handle the -ENOBUF situation properly in case called from net_tcp_queue_data. net_tcp_queue_data removes data from the send_data in case the transmission failed with -ENOBUF. This cause the buffer to be not full any more. Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
This commit is contained in:
parent
d49d06735a
commit
ebf8b6d3da
1 changed files with 13 additions and 9 deletions
|
@ -1020,6 +1020,11 @@ static int tcp_unsent_len(struct tcp *conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsent_len = conn->send_data_total - conn->unacked_len;
|
unsent_len = conn->send_data_total - conn->unacked_len;
|
||||||
|
if (conn->unacked_len >= conn->send_win) {
|
||||||
|
unsent_len = 0;
|
||||||
|
} else {
|
||||||
|
unsent_len = MIN(unsent_len, conn->send_win - conn->unacked_len);
|
||||||
|
}
|
||||||
out:
|
out:
|
||||||
NET_DBG("unsent_len=%d", unsent_len);
|
NET_DBG("unsent_len=%d", unsent_len);
|
||||||
|
|
||||||
|
@ -1092,21 +1097,12 @@ static int tcp_send_queued_data(struct tcp *conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tcp_unsent_len(conn) > 0) {
|
while (tcp_unsent_len(conn) > 0) {
|
||||||
if (tcp_window_full(conn)) {
|
|
||||||
subscribe = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = tcp_send_data(conn);
|
ret = tcp_send_data(conn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tcp_window_full(conn)) {
|
|
||||||
(void)k_sem_take(&conn->tx_sem, K_NO_WAIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conn->send_data_total) {
|
if (conn->send_data_total) {
|
||||||
subscribe = true;
|
subscribe = true;
|
||||||
}
|
}
|
||||||
|
@ -2070,6 +2066,10 @@ next_state:
|
||||||
close_status = ret;
|
close_status = ret;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tcp_window_full(conn)) {
|
||||||
|
(void)k_sem_take(&conn->tx_sem, K_NO_WAIT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (th) {
|
if (th) {
|
||||||
|
@ -2377,6 +2377,10 @@ int net_tcp_queue_data(struct net_context *context, struct net_pkt *pkt)
|
||||||
k_work_cancel_delayable(&conn->send_data_timer);
|
k_work_cancel_delayable(&conn->send_data_timer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (tcp_window_full(conn)) {
|
||||||
|
(void)k_sem_take(&conn->tx_sem, K_NO_WAIT);
|
||||||
|
}
|
||||||
|
|
||||||
/* We should not free the pkt if there was an error. It will be
|
/* We should not free the pkt if there was an error. It will be
|
||||||
* freed in net_context.c:context_sendto()
|
* freed in net_context.c:context_sendto()
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue