Commit ae042175 authored by Kirill Smelkov's avatar Kirill Smelkov

.

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