Skip to content

Commit

Permalink
Check if error is nil in proxy listener (networkservicemesh#407)
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
  • Loading branch information
Vladimir Popov authored Oct 13, 2021
1 parent a355afd commit a57956d
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions pkg/networkservice/mechanisms/memif/memifproxy/proxy_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,30 @@ func (p *proxyListener) accept() {
defer func() { _ = p.Close() }()
for {
in, err := p.listener.Accept()
if optErr, ok := err.(*net.OpError); !ok || !optErr.Temporary() {
// TODO - perhaps log this?
return
if err != nil {
if optErr, ok := err.(*net.OpError); !ok || !optErr.Temporary() {
// TODO - perhaps log this?
return
}
}

out, err := net.Dial(memifNetwork, p.socketFilename)
if optErr, ok := err.(*net.OpError); !ok || !optErr.Temporary() {
_ = in.Close()
// TODO - perhaps log this?
return
if err != nil {
if optErr, ok := err.(*net.OpError); !ok || !optErr.Temporary() {
_ = in.Close()
// TODO - perhaps log this?
return
}
}

proxyConn, err := newProxyConnection(in, out)
if err != nil {
_ = in.Close()
_ = out.Close()
// TODO - perhaps log this?
return
}

// TODO - clean up - while 99% of the time this won't be an issue because we will have exactly one thing
// in this list... in principle it could leak memory
p.proxyConnections = append(p.proxyConnections, proxyConn)
Expand Down

0 comments on commit a57956d

Please sign in to comment.