github-vet / github-vet/rangeloop-pointer-findings
FTwOoO/go-ss: dialer/connection/multi_connection_manager.go; 45 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [FTwOoO/go-ss](https://www.github.com/FTwOoO/go-ss) at [dialer/connection/multi_connection_manager.go](https://github.com/FTwOoO/go-ss/blob/c5627d72b293fcd1fab5b402410a32047de5e31b/dialer/connection/multi_connection_manager.go#L109-L153)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> range-loop variable l used in defer or goroutine at line 114
[Click here to see the code in its original context.](https://github.com/FTwOoO/go-ss/blob/c5627d72b293fcd1fab5b402410a32047de5e31b/dialer/connection/multi_connection_manager.go#L109-L153)
Click here to show the 45 line(s) of Go which triggered the analyzer.
```go
for _, l := range []net.Listener{l1, l2} {
go func() {
for {
select {
case <-ctx.Done():
l.Close()
return
default:
c, err := l.Accept()
if err != nil {
log.Printf("failed to accept: %s", err)
return
}
if c1, ok := c.(*net.TCPConn); ok {
c1.SetKeepAlive(true)
}
c1 := NewInnerConnection(c, 0)
err = c1.ReadHeader()
if err != nil {
log.Print(err)
continue
}
mc.connsLock.RLock()
multiConn, ok := mc.conns[c1.Id()]
mc.connsLock.RUnlock()
if ok {
multiConn.Add(c1)
} else {
multiConn = NewMultiConnectionById(c1.Id())
multiConn.Add(c1)
mc.connsLock.Lock()
mc.conns[c1.connId] = multiConn
mc.connsLock.Unlock()
mc.acceptConns <- multiConn
}
}
}
}()
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: c5627d72b293fcd1fab5b402410a32047de5e31b
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.