summaryrefslogtreecommitdiff
path: root/recipes-bsp/u-boot/u-boot-2016.09.01/tftpput.patch
blob: b5e419f6bd085b895a225f7b6cafd4db1b9a4448 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * tftpput in u-boot has two issues.  It never resets the timeout, so
 * tftpput must complete within the timeout perious (by defaut 5 seconds)
 * and it does not properly handle the block wrap at 65535 back to zero,
 * so it will transmit data forever, or at least a very long time, if
 * the timeout is set long enough, or the timeout issue is patched by
 * itself.
 */
diff -Naru old/net/tftp.c new/net/tftp.c
--- old/net/tftp.c	2017-07-05 15:52:28.865818329 -0500
+++ new/net/tftp.c	2017-07-11 16:15:27.870430395 -0500
@@ -499,10 +499,15 @@
 				int block = ntohs(*s);
 				int ack_ok = (tftp_cur_block == block);
 
+				/* update_block_number needs tftp_prev_block */
+                tftp_prev_block = tftp_cur_block;
 				tftp_cur_block = (unsigned short)(block + 1);
 				update_block_number();
-				if (ack_ok)
+				if (ack_ok) {
+					/* We got the ACK, so reset the timeout */
+					net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
 					tftp_send(); /* Send next data block */
+				}
 			}
 		}
 #endif