Commit a41e0b4d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7025320e
...@@ -372,7 +372,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) { ...@@ -372,7 +372,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
var serveConn func(context.Context, *neo.Conn) var serveConn func(context.Context, *neo.Conn)
switch nodeInfo.NodeType { switch nodeInfo.NodeType {
case neo.CLIENT: case neo.CLIENT:
serveConn = stor.ServeClient serveConn = stor.serveClient
default: default:
// XXX vvv should be reply to peer // XXX vvv should be reply to peer
...@@ -388,7 +388,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) { ...@@ -388,7 +388,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
break break
} }
// XXX wrap conn close to happen here, not in ServeClient ? // XXX wrap conn close to happen here, not in serveClient ?
go serveConn(ctx, conn) go serveConn(ctx, conn)
} }
...@@ -396,9 +396,9 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) { ...@@ -396,9 +396,9 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
} }
// ServeClient serves incoming connection on which peer identified itself as client // serveClient serves incoming connection on which peer identified itself as client
// 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)
// rederive ctx to be also cancelled if M tells us StopOperation // rederive ctx to be also cancelled if M tells us StopOperation
...@@ -418,6 +418,12 @@ func (stor *Storage) ServeClient(ctx context.Context, conn *neo.Conn) { ...@@ -418,6 +418,12 @@ func (stor *Storage) ServeClient(ctx context.Context, conn *neo.Conn) {
}() }()
for { for {
serveClient1(conn) // XXX err check
}
}
// serveClient1 serves 1 request from a client
func (stor *Storage) serveClient1(conn *neo.Conn) error {
req, err := conn.Recv() req, err := conn.Recv()
if err != nil { if err != nil {
return // XXX log / err / send error before closing return // XXX log / err / send error before closing
...@@ -475,5 +481,4 @@ func (stor *Storage) ServeClient(ctx context.Context, conn *neo.Conn) { ...@@ -475,5 +481,4 @@ func (stor *Storage) ServeClient(ctx context.Context, conn *neo.Conn) {
} }
//req.Put(...) //req.Put(...)
}
} }
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