From 70a8b6d45b2970b9c00a49d98a77e245150c10f8 Mon Sep 17 00:00:00 2001 From: asomers Date: Mon, 1 Oct 2018 15:43:56 +0000 Subject: [PATCH] MFC r336587: tftpd(8): when completing an WRQ, flush the file before acknowleding receipt tftpd(8) should flush a newly written file to disk before ACKing the final DATA packet. Otherwise there is a narrow race window when a subsequent read may not see the file. This is somewhat related to r330710, but the race window is much smaller. Hopefully this will fix the intermittent tests in Jenkins. Reported by: Jenkins --- libexec/tftpd/tftp-transfer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libexec/tftpd/tftp-transfer.c b/libexec/tftpd/tftp-transfer.c index 0311c07b08d..9c350084afa 100644 --- a/libexec/tftpd/tftp-transfer.c +++ b/libexec/tftpd/tftp-transfer.c @@ -277,6 +277,8 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts, send_error(peer, ENOSPACE); goto abort; } + if (n_data != segsize) + write_close(); } send_ack: @@ -302,8 +304,6 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts, gettimeofday(&(ts->tstop), NULL); } while (n_data == segsize); - write_close(); - /* Don't do late packet management for the client implementation */ if (acting_as_client) return; -- 2.45.0