Skip to content

Commit 2722cb9

Browse files
handle send retry when SSH window is full
1 parent 40aabc2 commit 2722cb9

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

apps/wolfsshd/wolfsshd.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,17 +1495,19 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
14951495
/* if the window was previously full, try resending the data */
14961496
if (windowFull) {
14971497
cnt_w = wolfSSH_ChannelIdSend(ssh, shellChannelId,
1498-
shellBuffer, cnt_r);
1498+
shellBuffer, windowFull);
14991499
if (cnt_w == WS_WINDOW_FULL) {
1500-
windowFull = 1;
15011500
continue;
15021501
}
15031502
else if (cnt_w == WS_WANT_WRITE) {
1504-
windowFull = 1;
15051503
continue;
15061504
}
15071505
else {
1508-
windowFull = 0;
1506+
windowFull -= cnt_w;
1507+
if (windowFull > 0)
1508+
continue;
1509+
if (windowFull < 0)
1510+
windowFull = 0;
15091511
}
15101512
}
15111513

@@ -1525,7 +1527,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
15251527
cnt_w = wolfSSH_extended_data_send(ssh, shellBuffer,
15261528
cnt_r);
15271529
if (cnt_w == WS_WINDOW_FULL) {
1528-
windowFull = 1;
1530+
windowFull = cnt_r; /* save amount to be sent */
15291531
continue;
15301532
}
15311533
else if (cnt_w == WS_WANT_WRITE) {
@@ -1557,7 +1559,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
15571559
cnt_w = wolfSSH_ChannelIdSend(ssh, shellChannelId,
15581560
shellBuffer, cnt_r);
15591561
if (cnt_w == WS_WINDOW_FULL) {
1560-
windowFull = 1;
1562+
windowFull = cnt_r; /* save amount to be sent */
15611563
continue;
15621564
}
15631565
else if (cnt_w == WS_WANT_WRITE) {

0 commit comments

Comments
 (0)