Commit 5a938a10 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7ecadf55
...@@ -155,16 +155,16 @@ func (stor *Storage) talkMaster(ctx context.Context) error { ...@@ -155,16 +155,16 @@ func (stor *Storage) talkMaster(ctx context.Context) error {
// talkMaster1 does 1 cycle of connect/talk/disconnect to master // talkMaster1 does 1 cycle of connect/talk/disconnect to master
// it returns error describing why such cycle had to finish // it returns error describing why such cycle had to finish
// XXX distinguish between temporary problems and non-temporary ones? // XXX distinguish between temporary problems and non-temporary ones?
func (stor *Storage) talkMaster1(ctx context.Context) error { func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
Mlink, err := neo.Dial(ctx, stor.net, stor.masterAddr) Mlink, err := neo.Dial(ctx, stor.net, stor.masterAddr)
if err != nil { if err != nil {
return err return err
} }
// close Mlink on return / cancel
defer func() { defer func() {
errClose := Mlink.Close() errClose := Mlink.Close()
err = xerr.First(err, errClose) err = xerr.First(err, errClose)
// TODO Mlink.Close() on return / cancel
}() }()
// request identification this way registering our node to master // request identification this way registering our node to master
...@@ -400,6 +400,7 @@ func (stor *Storage) withWhileOperational(ctx context.Context) (context.Context, ...@@ -400,6 +400,7 @@ func (stor *Storage) withWhileOperational(ctx context.Context) (context.Context,
} }
// serveClient serves incoming connection on which peer identified itself as client // serveClient serves incoming connection on which peer identified itself as client
// 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) fmt.Printf("stor: %s: serving new client conn\n", conn)
...@@ -427,12 +428,14 @@ func (stor *Storage) serveClient(ctx context.Context, conn *neo.Conn) { ...@@ -427,12 +428,14 @@ func (stor *Storage) serveClient(ctx context.Context, conn *neo.Conn) {
select { select {
case <-ctx.Done(): case <-ctx.Done():
// XXX tell client we are shutting down? // XXX tell client we are shutting down?
// XXX should we also wait for main work to finish?
err = ctx.Err() err = ctx.Err()
case err = <-done: case err = <-done:
} }
fmt.Printf("stor: %v: %v\n", conn, err) fmt.Printf("stor: %v: %v\n", conn, err)
// XXX vvv -> defer ?
fmt.Printf("stor: %v: closing client conn\n", conn) fmt.Printf("stor: %v: closing client conn\n", 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