mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-12-02 14:35:22 +00:00
Merge pull request #514 from Arceliar/bugfix
hopefully prevent a deadlock
This commit is contained in:
commit
f9d28e80df
@ -69,7 +69,6 @@ func (d *Dialer) DialByNodeIDandMask(nodeID, nodeMask *crypto.NodeID) (*Conn, er
|
|||||||
defer t.Stop()
|
defer t.Stop()
|
||||||
select {
|
select {
|
||||||
case <-conn.session.init:
|
case <-conn.session.init:
|
||||||
conn.session.startWorkers()
|
|
||||||
return conn, nil
|
return conn, nil
|
||||||
case <-t.C:
|
case <-t.C:
|
||||||
conn.Close()
|
conn.Close()
|
||||||
|
@ -259,6 +259,7 @@ func (ss *sessions) createSession(theirPermKey *crypto.BoxPubKey) *sessionInfo {
|
|||||||
<-sinfo.cancel.Finished()
|
<-sinfo.cancel.Finished()
|
||||||
sinfo.core.router.doAdmin(sinfo.close)
|
sinfo.core.router.doAdmin(sinfo.close)
|
||||||
}()
|
}()
|
||||||
|
go sinfo.startWorkers()
|
||||||
return &sinfo
|
return &sinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +387,6 @@ func (ss *sessions) handlePing(ping *sessionPing) {
|
|||||||
for i := range conn.nodeMask {
|
for i := range conn.nodeMask {
|
||||||
conn.nodeMask[i] = 0xFF
|
conn.nodeMask[i] = 0xFF
|
||||||
}
|
}
|
||||||
conn.session.startWorkers()
|
|
||||||
c := ss.listener.conn
|
c := ss.listener.conn
|
||||||
go func() { c <- conn }()
|
go func() { c <- conn }()
|
||||||
}
|
}
|
||||||
@ -568,6 +568,12 @@ func (sinfo *sessionInfo) recvWorker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
select {
|
||||||
|
case <-sinfo.cancel.Finished():
|
||||||
|
return
|
||||||
|
case <-sinfo.init:
|
||||||
|
// Wait until the session has finished initializing before processing any packets
|
||||||
|
}
|
||||||
for {
|
for {
|
||||||
for len(callbacks) > 0 {
|
for len(callbacks) > 0 {
|
||||||
select {
|
select {
|
||||||
@ -634,6 +640,12 @@ func (sinfo *sessionInfo) sendWorker() {
|
|||||||
util.WorkerGo(poolFunc)
|
util.WorkerGo(poolFunc)
|
||||||
callbacks = append(callbacks, ch)
|
callbacks = append(callbacks, ch)
|
||||||
}
|
}
|
||||||
|
select {
|
||||||
|
case <-sinfo.cancel.Finished():
|
||||||
|
return
|
||||||
|
case <-sinfo.init:
|
||||||
|
// Wait until the session has finished initializing before processing any packets
|
||||||
|
}
|
||||||
for {
|
for {
|
||||||
for len(callbacks) > 0 {
|
for len(callbacks) > 0 {
|
||||||
select {
|
select {
|
||||||
|
Loading…
Reference in New Issue
Block a user