[rtems-tools commit] tester: Avoid TFTP race condition

Joel Sherrill joel at rtems.org
Tue May 18 19:04:04 UTC 2021


Module:    rtems-tools
Branch:    master
Commit:    a918844889eb603622bb78f81139a5e20a71ab6b
Changeset: http://git.rtems.org/rtems-tools/commit/?id=a918844889eb603622bb78f81139a5e20a71ab6b

Author:    Kinsey Moore <kinsey.moore at oarcorp.com>
Date:      Mon May 17 13:24:48 2021 -0500

tester: Avoid TFTP race condition

The u-boot TFTP client will fail a fully completed file retrieval if the
final ACK gets an ICMP response that the port is unavailable which can
occur if the port is closed before the ACK arrives from the client. This
change causes the TFTP server to wait for the final ACK before closing
the socket and prevents transfers from failing due to the race
condition.

---

 tester/rt/tftpserver.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tester/rt/tftpserver.py b/tester/rt/tftpserver.py
index d733301..46b594f 100644
--- a/tester/rt/tftpserver.py
+++ b/tester/rt/tftpserver.py
@@ -418,8 +418,6 @@ class udp_handler(socketserver.BaseRequestHandler):
                             ' < ' +
                             session.decode(client_ip, client_port, response))
                     sock.sendto(response, (client_ip, client_port))
-                    if session.finished:
-                        break
                     try:
                         data, address = sock.recvfrom(2 + 2 +
                                                       session.get_block_size())
@@ -438,6 +436,8 @@ class udp_handler(socketserver.BaseRequestHandler):
                             log.trace('] tftp: %d: receive: %s: error: %s' \
                                       % (index, client, serr))
                         return
+                    if session.finished:
+                        break
                     response = session.process(address[0], address[1], data)
         except error.general as gerr:
             self._notice('] tftp: %dd: error: %s' % (index, gerr))



More information about the vc mailing list