5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-29 13:11:36 +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:
Arceliar 2019-08-27 20:01:37 -05:00
parent 3845f81357
commit a8b323acdd

View File

@ -482,6 +482,18 @@ func (ss *sessions) reset() {
//////////////////////////// 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 {
FlowKey uint64
Message []byte
@ -527,7 +539,7 @@ func (sinfo *sessionInfo) _recvPacket(p *wire_trafficPacket) {
sinfo.checkCallbacks()
}
sinfo.callbacks = append(sinfo.callbacks, ch)
util.WorkerGo(poolFunc)
manager.workerGo(sinfo, poolFunc)
}
func (sinfo *sessionInfo) _send(msg FlowKeyMessage) {
@ -570,7 +582,7 @@ func (sinfo *sessionInfo) _send(msg FlowKeyMessage) {
sinfo.checkCallbacks()
}
sinfo.callbacks = append(sinfo.callbacks, ch)
util.WorkerGo(poolFunc)
manager.workerGo(sinfo, poolFunc)
}
func (sinfo *sessionInfo) checkCallbacks() {