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
MFC after:	2 weeks
This commit is contained in:
Alan Somers 2018-07-21 19:48:31 +00:00
parent 85e089fe36
commit 7378015b69

View File

@ -279,6 +279,8 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts,
send_error(peer, ENOSPACE); send_error(peer, ENOSPACE);
goto abort; goto abort;
} }
if (n_data != segsize)
write_close();
} }
send_ack: send_ack:
@ -304,8 +306,6 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts,
gettimeofday(&(ts->tstop), NULL); gettimeofday(&(ts->tstop), NULL);
} while (n_data == segsize); } while (n_data == segsize);
write_close();
/* Don't do late packet management for the client implementation */ /* Don't do late packet management for the client implementation */
if (acting_as_client) if (acting_as_client)
return; return;