Skip to content
This repository was archived by the owner on Jul 4, 2026. It is now read-only.

Commit 3e9b103

Browse files
committed
fix(server): re-check upload TTL under sess.mu to close evict race
A concurrent evictExpired could delete a session from the map after Append fetched it but before Append acquired sess.mu. Append would then write bytes and report success, while eviction proceeded to close the tempfile — silently discarding the just-acknowledged bytes.
1 parent 2e2b4e5 commit 3e9b103

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

server/uploads.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,12 @@ func (u *uploadSessions) Append(id string, src io.Reader) (int64, error) {
139139

140140
sess.mu.Lock()
141141
defer sess.mu.Unlock()
142-
if sess.poisoned {
142+
// Re-check TTL under sess.mu: a concurrent evictExpired may have
143+
// removed this session from the map between our lookup and lock
144+
// acquisition. Without this guard, the Append would return success
145+
// for bytes that are immediately discarded when eviction proceeds to
146+
// close the tempfile.
147+
if sess.poisoned || u.now().Sub(sess.createdAt) > u.ttl {
143148
return sess.size, errUploadNotFound
144149
}
145150

0 commit comments

Comments
 (0)