Commit 48e38f91 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 2c0345b9
...@@ -949,7 +949,7 @@ func (c *Conn) Expect(msgv ...Msg) (which int, err error) { ...@@ -949,7 +949,7 @@ func (c *Conn) Expect(msgv ...Msg) (which int, err error) {
return -1, &ConnError{c, "recv", fmt.Errorf("unexpected message: %v", msgType)} return -1, &ConnError{c, "recv", fmt.Errorf("unexpected message: %v", msgType)}
} }
// Ask sends request and receives response // Ask sends request and receives response.
// It expects response to be exactly of resp type and errors otherwise // It expects response to be exactly of resp type and errors otherwise
// XXX clarify error semantic (when Error is decoded) // XXX clarify error semantic (when Error is decoded)
// XXX do the same as Expect wrt respv ? // XXX do the same as Expect wrt respv ?
......
This diff is collapsed.
...@@ -143,9 +143,9 @@ func (stor *Storage) talkMaster(ctx context.Context) error { ...@@ -143,9 +143,9 @@ func (stor *Storage) talkMaster(ctx context.Context) error {
// XXX errctx // XXX errctx
for { for {
fmt.Printf("stor: master(%v): connecting\n", stor.node.MasterAddr) // XXX info stor.vlogf("master(%v): connecting ...", stor.node.MasterAddr)
err := stor.talkMaster1(ctx) err := stor.talkMaster1(ctx)
fmt.Printf("stor: master(%v): %v\n", stor.node.MasterAddr, err) stor.logf("master(%v): %v", stor.node.MasterAddr, err)
// TODO if err = shutdown -> return // TODO if err = shutdown -> return
...@@ -186,7 +186,7 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) { ...@@ -186,7 +186,7 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
// XXX -> node.Dial ? // XXX -> node.Dial ?
if accept.YourNodeUUID != stor.node.MyInfo.NodeUUID { if accept.YourNodeUUID != stor.node.MyInfo.NodeUUID {
fmt.Printf("stor: %v: master told us to have UUID=%v\n", Mlink, accept.YourNodeUUID) stor.logf("%v: master told us to have UUID=%v", Mlink, accept.YourNodeUUID)
stor.node.MyInfo.NodeUUID = accept.YourNodeUUID stor.node.MyInfo.NodeUUID = accept.YourNodeUUID
} }
...@@ -224,13 +224,13 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) { ...@@ -224,13 +224,13 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
// let master initialize us. If successful this ends with StartOperation command. // let master initialize us. If successful this ends with StartOperation command.
err = stor.m1initialize(ctx, Mconn) err = stor.m1initialize(ctx, Mconn)
if err != nil { if err != nil {
fmt.Println("stor: %v: master: %v", err) stor.logf("%v: master: %v", Mconn, err)
continue // retry initializing continue // retry initializing
} }
// we got StartOperation command. Let master drive us during servicing phase. // we got StartOperation command. Let master drive us during servicing phase.
err = stor.m1serve(ctx, Mconn) err = stor.m1serve(ctx, Mconn)
fmt.Println("stor: %v: master: %v", err) stor.logf("%v: master: %v", Mconn, err)
continue // retry from initializing continue // retry from initializing
} }
...@@ -358,7 +358,7 @@ func (stor *Storage) m1serve(ctx context.Context, Mconn *neo.Conn) (err error) { ...@@ -358,7 +358,7 @@ func (stor *Storage) m1serve(ctx context.Context, Mconn *neo.Conn) (err error) {
// ServeLink serves incoming node-node link connection // ServeLink serves incoming node-node link connection
// XXX +error return? // XXX +error return?
func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) { func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
fmt.Printf("stor: %s: serving new node\n", link) stor.logf("%s: serving new node", link)
// close link when either cancelling or returning (e.g. due to an error) // close link when either cancelling or returning (e.g. due to an error)
// ( when cancelling - link.Close will signal to all current IO to // ( when cancelling - link.Close will signal to all current IO to
...@@ -373,7 +373,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) { ...@@ -373,7 +373,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
// XXX ret err = ctx.Err() // XXX ret err = ctx.Err()
case <-retch: case <-retch:
} }
fmt.Printf("stor: %v: closing link\n", link) stor.logf("%v: closing link", link)
link.Close() // XXX err link.Close() // XXX err
}() }()
...@@ -381,7 +381,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) { ...@@ -381,7 +381,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
// XXX only accept when operational (?) // XXX only accept when operational (?)
nodeInfo, err := IdentifyPeer(link, neo.STORAGE) nodeInfo, err := IdentifyPeer(link, neo.STORAGE)
if err != nil { if err != nil {
fmt.Printf("stor: %v\n", err) stor.logf("%v", err)
return return
} }
...@@ -392,7 +392,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) { ...@@ -392,7 +392,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
default: default:
// XXX vvv should be reply to peer // XXX vvv should be reply to peer
fmt.Printf("stor: %v: unexpected peer type: %v\n", link, nodeInfo.NodeType) stor.logf("%v: unexpected peer type: %v", link, nodeInfo.NodeType)
return return
} }
...@@ -400,7 +400,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) { ...@@ -400,7 +400,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
for { for {
conn, err := link.Accept() conn, err := link.Accept()
if err != nil { if err != nil {
fmt.Printf("stor: %v\n", err) // XXX err ctx stor.logf("%v", err) // XXX err ctx
break break
} }
...@@ -426,7 +426,7 @@ func (stor *Storage) withWhileOperational(ctx context.Context) (context.Context, ...@@ -426,7 +426,7 @@ func (stor *Storage) withWhileOperational(ctx context.Context) (context.Context,
// the connection is closed when serveClient returns // the connection is closed when serveClient returns
// XXX +error return? // XXX +error return?
func (stor *Storage) serveClient(ctx context.Context, conn *neo.Conn) { func (stor *Storage) serveClient(ctx context.Context, conn *neo.Conn) {
fmt.Printf("stor: %s: serving new client conn\n", conn) stor.logf("%s: serving new client conn", conn)
// rederive ctx to be also cancelled if M tells us StopOperation // rederive ctx to be also cancelled if M tells us StopOperation
ctx, cancel := stor.withWhileOperational(ctx) ctx, cancel := stor.withWhileOperational(ctx)
...@@ -457,9 +457,9 @@ func (stor *Storage) serveClient(ctx context.Context, conn *neo.Conn) { ...@@ -457,9 +457,9 @@ func (stor *Storage) serveClient(ctx context.Context, conn *neo.Conn) {
case err = <-done: case err = <-done:
} }
fmt.Printf("stor: %v: %v\n", conn, err) stor.logf("%v: %v", conn, err)
// XXX vvv -> defer ? // XXX vvv -> defer ?
fmt.Printf("stor: %v: closing client conn\n", conn) stor.logf("%v: closing client conn", conn)
conn.Close() // XXX err conn.Close() // XXX err
} }
......
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