Commit db33a386 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8785e160
...@@ -105,7 +105,7 @@ package lonet ...@@ -105,7 +105,7 @@ package lonet
import ( import (
"context" "context"
"errors" stderrors "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
...@@ -116,6 +116,8 @@ import ( ...@@ -116,6 +116,8 @@ import (
"strconv" "strconv"
"sync" "sync"
"github.com/pkg/errors"
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xnet" "lab.nexedi.com/kirr/go123/xnet"
) )
...@@ -123,10 +125,10 @@ import ( ...@@ -123,10 +125,10 @@ import (
const NetPrefix = "lonet" // lonet package creates only "lonet*" networks const NetPrefix = "lonet" // lonet package creates only "lonet*" networks
var ( var (
// errNetClosed = errors.New("network connection closed") // errNetClosed = stderrors.New("network connection closed")
// errAddrAlreadyUsed = errors.New("address already in use") // errAddrAlreadyUsed = stderrors.New("address already in use")
// errAddrNoListen = errors.New("cannot listen on requested address") // errAddrNoListen = stderrors.New("cannot listen on requested address")
errConnRefused = errors.New("connection refused") errConnRefused = stderrors.New("connection refused")
) )
// Addr represents address of a lonet endpoint. // Addr represents address of a lonet endpoint.
...@@ -324,7 +326,7 @@ func (n *SubNetwork) serve() { // XXX error? ...@@ -324,7 +326,7 @@ func (n *SubNetwork) serve() { // XXX error?
go func() { go func() {
err := n.loaccept(osconn) // XXX + ctx? err := n.loaccept(osconn) // XXX + ctx?
if err != nil { if err != nil && errors.Cause(err) != errConnRefused {
log.Print(err) // XXX ok? log.Print(err) // XXX ok?
} }
}() }()
...@@ -345,7 +347,7 @@ func (n *SubNetwork) loaccept(osconn net.Conn) (err error) { ...@@ -345,7 +347,7 @@ func (n *SubNetwork) loaccept(osconn net.Conn) (err error) {
} }
}() }()
defer xerr.Contextf(&err, "lonet %q: handshake", n.network) defer xerr.Contextf(&err, "lonet %q: accept", n.network)
// read handshake line and parse it // read handshake line and parse it
line, err := readline(osconn, 1024) // limit line length not to cause memory dos line, err := readline(osconn, 1024) // limit line length not to cause memory dos
...@@ -396,6 +398,8 @@ func (n *SubNetwork) loaccept(osconn net.Conn) (err error) { ...@@ -396,6 +398,8 @@ func (n *SubNetwork) loaccept(osconn net.Conn) (err error) {
return ereplyf("dst address invalid") return ereplyf("dst address invalid")
} }
defer xerr.Contextf(&err, "%s -> %s", src, dst)
// check dst host:port in .hostMap // check dst host:port in .hostMap
n.mu.Lock() n.mu.Lock()
host := n.hostMap[adst.Host] host := n.hostMap[adst.Host]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment