Commit ae042175 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent af92856b
......@@ -325,17 +325,18 @@ type dialed struct {
// In case Dial returns an error - future Dial will attempt to reconnect with
// "don't reconnect too fast" throttling.
func (p *PeerNode) Dial(ctx context.Context) (*neonet.NodeLink, error) {
p.linkMu.Lock()
l := p.link
l.linkMu.Lock()
// ok if already connected
if link := p.link; link != nil {
p.linkMu.Unlock()
if link := l.link; link != nil {
l.linkMu.Unlock()
return link, nil
}
// if dial is already in progress - wait for its completion
if dialing := p.dialing; dialing != nil {
p.linkMu.Unlock()
if dialing := l.dialing; dialing != nil {
l.linkMu.Unlock()
select {
case <-ctx.Done():
......@@ -351,10 +352,10 @@ func (p *PeerNode) Dial(ctx context.Context) (*neonet.NodeLink, error) {
// XXX p.State != RUNNING
// XXX p.Addr != ""
dialT := p.dialT
dialT := l.dialT
dialing := &dialed{ready: make(chan struct{})}
p.dialing = dialing
p.linkMu.Unlock()
l.dialing = dialing
l.linkMu.Unlock()
go func() {
link, err := func() (*neonet.NodeLink, error) {
......@@ -370,16 +371,16 @@ func (p *PeerNode) Dial(ctx context.Context) (*neonet.NodeLink, error) {
}
}
link, err := p.dial(ctx)
link, err := l.dial(ctx)
dialT = time.Now()
return link, err
}()
p.linkMu.Lock()
p.link = link
p.dialT = dialT
p.dialing = nil
p.linkMu.Unlock()
l.linkMu.Lock()
l.link = link
l.dialT = dialT
l.dialing = nil
l.linkMu.Unlock()
dialing.link = link
dialing.err = err
......
......@@ -20,6 +20,12 @@
package xneo
// transactional log of states
import (
"sync"
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
// State represents state of a cluster.
type State struct {
// XXX +transaction ID?
......
......@@ -23,7 +23,7 @@ package xneo
//go:generate gotrace gen .
import (
"sync"
// "sync"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/neo/go/neo/proto"
......
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