Files
gotgt/pkg/api/client/transport/cancellable/canceler.go
Lei Xue f1cec4f5d4 fix regex, remove unsafe pointer usage, and add graceful HTTP shutdown
- 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>
2026-03-14 18:27:56 +08:00

28 lines
524 B
Go

// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build go1.5
// +build go1.5
package cancellable
import (
"net/http"
"github.com/gostor/gotgt/pkg/api/client/transport"
)
func canceler(client transport.Sender, req *http.Request) func() {
// Respect any existing value of req.Cancel.
if req.Cancel != nil {
return nop
}
ch := make(chan struct{})
req.Cancel = ch
return func() {
close(ch)
}
}