tailscale/taildrop
Joe Tsai 6ada33db77
taildrop: fix theoretical race condition in fileDeleter.Init (#9876)
It is possible that upon a cold-start, we enqueue a partial file
for deletion that is resumed shortly after startup.

If the file transfer happens to last longer than deleteDelay,
we will delete the partial file, which is unfortunate.
The client spent a long time uploading a file,
only for it to be accidentally deleted.
It's a very rare race, but also a frustrating one
if it happens to manifest.

Fix the code to only delete partial files that
do not have an active puts against it.

We also fix a minor bug in ResumeReader
where we read b[:blockSize] instead of b[:cs.Size].
The former is the fixed size of 64KiB,
while the latter is usually 64KiB,
but may be less for the last block.

Updates tailscale/corp#14772

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2023-10-19 13:26:55 -07:00
..
delete.go taildrop: fix theoretical race condition in fileDeleter.Init (#9876) 2023-10-19 13:26:55 -07:00
delete_test.go taildrop: fix theoretical race condition in fileDeleter.Init (#9876) 2023-10-19 13:26:55 -07:00
resume.go taildrop: fix theoretical race condition in fileDeleter.Init (#9876) 2023-10-19 13:26:55 -07:00
resume_test.go taildrop: fix TestResume (#9874) 2023-10-18 18:07:30 -07:00
retrieve.go taildrop: fix theoretical race condition in fileDeleter.Init (#9876) 2023-10-19 13:26:55 -07:00
send.go taildrop: implement asynchronous file deletion (#9844) 2023-10-17 13:46:05 -07:00
taildrop.go taildrop: fix theoretical race condition in fileDeleter.Init (#9876) 2023-10-19 13:26:55 -07:00
taildrop_test.go taildrop: implement asynchronous file deletion (#9844) 2023-10-17 13:46:05 -07:00