Commit 9de158d4 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d04fb093
......@@ -24,17 +24,10 @@ package xneo
import (
"context"
// "fmt"
"sync"
// "lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/neo/go/internal/log"
// "lab.nexedi.com/kirr/neo/go/internal/task"
// "lab.nexedi.com/kirr/neo/go/internal/xio"
// "lab.nexedi.com/kirr/neo/go/neo/neonet"
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
......@@ -90,84 +83,6 @@ func NewNode(net xnet.Networker, typ proto.NodeType, clusterName, masterAddr str
return node
}
// XXX kill -> xneo.Dial
// Dial connects to another node in the cluster.
//
// It handshakes, requests identification and checks peer type. If successful returned are:
//
// - established link
// - accept identification reply
//
// Dial does not update .NodeTab or its node entries in any way.
// For establishing links to peers present in .NodeTab use Node.Dial.
//
// XXX unexport after Node += talkMaster <- used only to dial to M
// <- dialing to other nodes always go through node.Dial
//
// XXX <- use dialNode instead
/*
func (node *Node) __Dial(ctx context.Context, peerType proto.NodeType, addr string) (_ *neonet.NodeLink, _ *proto.AcceptIdentification, err error) {
defer task.Runningf(&ctx, "dial %v (%v)", addr, peerType)(&err)
link, err := neonet.DialLink(ctx, node.Net, addr)
if err != nil {
return nil, nil, err
}
log.Info(ctx, "dialed ok; requesting identification...")
defer xerr.Contextf(&err, "%s: request identification", link)
// close link on error or FIXME: ctx cancel XXX -> xcontext.WithCloseOnErrCancel
//cleanup := xio.CloseWhenDone(ctx, link)
defer func() {
if err != nil {
// FIXME wrong - err=nil -> goroutine still left hanging waiting
// for ctx and will close link if dial ctx closes
// cleanup()
xio.LClose(ctx, link)
}
}()
req := &proto.RequestIdentification{
NodeType: node.MyInfo.Type,
NID: node.MyInfo.NID,
Address: node.MyInfo.Addr,
ClusterName: node.ClusterName,
IdTime: node.MyInfo.IdTime, // XXX ok?
DevPath: nil, // XXX stub
NewNID: nil, // XXX stub
}
accept := &proto.AcceptIdentification{}
// FIXME error if peer sends us something with another connID
// (currently we ignore and serveRecv will deadlock)
//
// XXX solution could be:
// link.CloseAccept()
// link.Ask1(req, accept)
// link.Listen()
// XXX but there is a race window in between recv in ask and listen
// start, and if peer sends new connection in that window it will be rejected.
//
// TODO thinking.
err = link.Ask1(req, accept)
if err != nil {
return nil, nil, err
}
// XXX vvv move out of here (e.g. to DialPeer) if we are not checking everthing in full here?
if accept.NodeType != peerType {
// XXX send Error to peer?
return nil, nil, fmt.Errorf("accepted, but peer is not %v (identifies as %v)", peerType, accept.NodeType)
}
// XXX accept.MyNID, link // XXX register .NodeTab? no -> LinkTab as NodeTab is driven by M
// XXX accept.YourNID // XXX M can tell us to change NID -> take in effect
log.Info(ctx, "identification accepted")
return link, accept, nil
}
*/
// ----------------------------------------
......
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