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>
This commit is contained in:
+1
-2
@@ -21,7 +21,6 @@ import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"sync"
|
||||
"unsafe"
|
||||
|
||||
"github.com/gostor/gotgt/pkg/api"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -96,7 +95,7 @@ func (s *SCSITargetService) AddCommandQueue(tid int, scmd *api.SCSICommand) erro
|
||||
}
|
||||
}
|
||||
scmd.ITNexus = itn
|
||||
lun := *(*uint64)(unsafe.Pointer(&scmd.Lun))
|
||||
lun := binary.LittleEndian.Uint64(scmd.Lun[:])
|
||||
scmd.Device = target.Devices[lun]
|
||||
|
||||
log.Debugf("scsi opcode: 0x%x, LUN: %d", int(scmd.SCB[0]), binary.LittleEndian.Uint64(scmd.Lun[:]))
|
||||
|
||||
Reference in New Issue
Block a user