Skip to content

fix regex, remove unsafe pointer usage, and add graceful HTTP shutdown#126

Merged
carmark merged 3 commits into
masterfrom
fix/unsafe-regex-shutdown
Mar 14, 2026
Merged

fix regex, remove unsafe pointer usage, and add graceful HTTP shutdown#126
carmark merged 3 commits into
masterfrom
fix/unsafe-regex-shutdown

Conversation

@carmark
Copy link
Copy Markdown
Contributor

@carmark carmark commented Mar 14, 2026

Summary

Reworked version of #120 by @orzhang, rebased on current master with review fixes applied.

  • Fix versionMatcher regex: gorilla/mux does not support (?:), changed to (-dirty)?
  • Remove unsafe.Pointer for LUN parsing: use binary.LittleEndian.Uint64 in sbc.go, scsi.go, target.go
  • Graceful HTTP server shutdown: use srv.Shutdown(ctx) with 5s timeout (no redundant listener close)
  • Use standard library context: replace golang.org/x/net/context with context
  • Respect existing req.Cancel: avoid overwriting already-set cancel channel
  • Early context check: fail fast if context is already cancelled

Supersedes #120

Test plan

  • go build ./... passes
  • go vet ./... passes
  • go test ./... all tests pass

carmark and others added 3 commits March 14, 2026 18:27
- Fix versionMatcher regex: gorilla/mux does not support (?:) syntax,
  and -dirty suffix was required instead of optional
- Replace unsafe.Pointer LUN casts with binary.LittleEndian.Uint64
  in sbc.go, scsi.go, and target.go
- Implement graceful HTTP server shutdown with 5s timeout using
  srv.Shutdown() instead of raw listener close
- Replace golang.org/x/net/context with standard library context
- Respect existing req.Cancel value in canceler to avoid overwriting
- Add early context cancellation check in Do() to fail fast

Based on review of PR #120 by @orzhang, with fixes applied.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gorilla/mux explicitly rejects capturing groups () in route regexps,
only non-capturing groups (?:) are allowed. The original regex was
missing the ? to make -dirty optional.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@carmark carmark merged commit 729b450 into master Mar 14, 2026
1 check passed
@carmark carmark deleted the fix/unsafe-regex-shutdown branch March 14, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant