mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-23 18:15:24 +00:00
have an actor manage the crypto worker pool instead of each session trying to use it directly, this should result in a fairer round-robin behavior in cases where crypto congestion is the bottleneck
This commit is contained in:
parent
3845f81357
commit
a8b323acdd
@ -482,6 +482,18 @@ func (ss *sessions) reset() {
|
|||||||
//////////////////////////// Worker Functions Below ////////////////////////////
|
//////////////////////////// Worker Functions Below ////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
type sessionCryptoManager struct {
|
||||||
|
phony.Inbox
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *sessionCryptoManager) workerGo(from phony.Actor, f func()) {
|
||||||
|
m.Act(from, func() {
|
||||||
|
util.WorkerGo(f)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var manager = sessionCryptoManager{}
|
||||||
|
|
||||||
type FlowKeyMessage struct {
|
type FlowKeyMessage struct {
|
||||||
FlowKey uint64
|
FlowKey uint64
|
||||||
Message []byte
|
Message []byte
|
||||||
@ -527,7 +539,7 @@ func (sinfo *sessionInfo) _recvPacket(p *wire_trafficPacket) {
|
|||||||
sinfo.checkCallbacks()
|
sinfo.checkCallbacks()
|
||||||
}
|
}
|
||||||
sinfo.callbacks = append(sinfo.callbacks, ch)
|
sinfo.callbacks = append(sinfo.callbacks, ch)
|
||||||
util.WorkerGo(poolFunc)
|
manager.workerGo(sinfo, poolFunc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sinfo *sessionInfo) _send(msg FlowKeyMessage) {
|
func (sinfo *sessionInfo) _send(msg FlowKeyMessage) {
|
||||||
@ -570,7 +582,7 @@ func (sinfo *sessionInfo) _send(msg FlowKeyMessage) {
|
|||||||
sinfo.checkCallbacks()
|
sinfo.checkCallbacks()
|
||||||
}
|
}
|
||||||
sinfo.callbacks = append(sinfo.callbacks, ch)
|
sinfo.callbacks = append(sinfo.callbacks, ch)
|
||||||
util.WorkerGo(poolFunc)
|
manager.workerGo(sinfo, poolFunc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sinfo *sessionInfo) checkCallbacks() {
|
func (sinfo *sessionInfo) checkCallbacks() {
|
||||||
|
Loading…
Reference in New Issue
Block a user