add lock for SCSI Target Service instance

This commit is contained in:
Donald Tang
2017-12-10 23:16:48 +08:00
parent 3803cc6249
commit 6d2a114697

View File

@@ -34,11 +34,12 @@ type SCSITargetService struct {
}
var _instance *SCSITargetService
var service sync.Once
func NewSCSITargetService() *SCSITargetService {
if _instance == nil {
service.Do(func() {
_instance = &SCSITargetService{Targets: []*api.SCSITarget{}}
}
})
return _instance
}