Commit 481da375 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 3b5bb769
...@@ -214,7 +214,8 @@ func (nl *NodeLink) shutdown() { ...@@ -214,7 +214,8 @@ func (nl *NodeLink) shutdown() {
} }
// Close closes node-node link. // Close closes node-node link.
// IO on connections established over it is automatically interrupted with an error. // All blocking operations - Accept and IO on associated connections
// established over node link - are automatically interrupted with an error.
func (nl *NodeLink) Close() error { func (nl *NodeLink) Close() error {
atomic.StoreUint32(&nl.closed, 1) atomic.StoreUint32(&nl.closed, 1)
nl.shutdown() nl.shutdown()
...@@ -236,6 +237,7 @@ func (c *Conn) shutdown() { ...@@ -236,6 +237,7 @@ func (c *Conn) shutdown() {
// background on the wire not to break node-node link framing. // background on the wire not to break node-node link framing.
func (c *Conn) Close() error { func (c *Conn) Close() error {
// adjust nodeLink.connTab // adjust nodeLink.connTab
// (if nodelink was already shutted down and connTab=nil - delete will be noop)
c.nodeLink.connMu.Lock() c.nodeLink.connMu.Lock()
delete(c.nodeLink.connTab, c.connId) delete(c.nodeLink.connTab, c.connId)
c.nodeLink.connMu.Unlock() c.nodeLink.connMu.Unlock()
...@@ -326,6 +328,7 @@ func (nl *NodeLink) serveRecv() { ...@@ -326,6 +328,7 @@ func (nl *NodeLink) serveRecv() {
connId := ntoh32(pkt.Header().ConnId) connId := ntoh32(pkt.Header().ConnId)
nl.connMu.Lock() nl.connMu.Lock()
// XXX connTab == nil here
conn := nl.connTab[connId] conn := nl.connTab[connId]
if conn == nil { if conn == nil {
if nl.acceptq != nil { if nl.acceptq != nil {
...@@ -345,12 +348,10 @@ func (nl *NodeLink) serveRecv() { ...@@ -345,12 +348,10 @@ func (nl *NodeLink) serveRecv() {
} }
// route packet to serving goroutine handler // route packet to serving goroutine handler
// XXX what if Conn.Recv exited because of just recently close(nl.down) ?
// -> check nl.down here too ?
conn.rxq <- pkt conn.rxq <- pkt
// keep connMu locked until here: so that ^^^ `conn.rxq <- pkt` can be // keep connMu locked until here: so that ^^^ `conn.rxq <- pkt` can be
// sure conn stays not down e.g. closed by Conn.Close // sure conn stays not down e.g. closed by Conn.Close or NodeLink.shutdown
nl.connMu.Unlock() nl.connMu.Unlock()
} }
} }
......
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