markUploadInFlight increments the in-flight counter for a content hash. Returns a release func the caller MUST defer; the release decrements and removes the entry once it hits zero. Used by the upload handler to fence Put + CreateAttachment against orphan-GC blob deletions of the same hash. Increme
(hash string)
| 748 | // LoadOrStore-then-atomic-add and missed that window (Codex P1 on |
| 749 | // PR #307 round 2). |
| 750 | func (s *Server) markUploadInFlight(hash string) func() { |
| 751 | s.inFlightHashesMu.Lock() |
| 752 | if s.inFlightHashes == nil { |
| 753 | s.inFlightHashes = make(map[string]int64) |
| 754 | } |
| 755 | s.inFlightHashes[hash]++ |
| 756 | s.inFlightHashesMu.Unlock() |
| 757 | return func() { |
| 758 | s.inFlightHashesMu.Lock() |
| 759 | defer s.inFlightHashesMu.Unlock() |
| 760 | s.inFlightHashes[hash]-- |
| 761 | if s.inFlightHashes[hash] <= 0 { |
| 762 | delete(s.inFlightHashes, hash) |
| 763 | } |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | // uploadInFlight reports whether any upload is currently materializing |
| 768 | // a blob with the given hash. The orphan GC consults this before |