mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-23 18:15:24 +00:00
use smaller buffer sizes for buffered channels
This commit is contained in:
parent
80a45b3859
commit
63aadf6e88
@ -41,7 +41,7 @@ type router struct {
|
|||||||
func (r *router) init(core *Core) {
|
func (r *router) init(core *Core) {
|
||||||
r.core = core
|
r.core = core
|
||||||
r.addr = *address_addrForNodeID(&r.core.dht.nodeID)
|
r.addr = *address_addrForNodeID(&r.core.dht.nodeID)
|
||||||
in := make(chan []byte, 1024) // TODO something better than this...
|
in := make(chan []byte, 32) // TODO something better than this...
|
||||||
p := r.core.peers.newPeer(&r.core.boxPub, &r.core.sigPub) //, out, in)
|
p := r.core.peers.newPeer(&r.core.boxPub, &r.core.sigPub) //, out, in)
|
||||||
p.out = func(packet []byte) {
|
p.out = func(packet []byte) {
|
||||||
// This is to make very sure it never blocks
|
// This is to make very sure it never blocks
|
||||||
@ -56,8 +56,8 @@ func (r *router) init(core *Core) {
|
|||||||
}
|
}
|
||||||
r.in = in
|
r.in = in
|
||||||
r.out = func(packet []byte) { p.handlePacket(packet, nil) } // The caller is responsible for go-ing if it needs to not block
|
r.out = func(packet []byte) { p.handlePacket(packet, nil) } // The caller is responsible for go-ing if it needs to not block
|
||||||
recv := make(chan []byte, 1024)
|
recv := make(chan []byte, 32)
|
||||||
send := make(chan []byte, 1024)
|
send := make(chan []byte, 32)
|
||||||
r.recv = recv
|
r.recv = recv
|
||||||
r.send = send
|
r.send = send
|
||||||
r.core.tun.recv = recv
|
r.core.tun.recv = recv
|
||||||
|
@ -163,8 +163,8 @@ func (ss *sessions) createSession(theirPermKey *boxPubKey) *sessionInfo {
|
|||||||
sinfo.myHandle = *newHandle()
|
sinfo.myHandle = *newHandle()
|
||||||
sinfo.theirAddr = *address_addrForNodeID(getNodeID(&sinfo.theirPermPub))
|
sinfo.theirAddr = *address_addrForNodeID(getNodeID(&sinfo.theirPermPub))
|
||||||
sinfo.theirSubnet = *address_subnetForNodeID(getNodeID(&sinfo.theirPermPub))
|
sinfo.theirSubnet = *address_subnetForNodeID(getNodeID(&sinfo.theirPermPub))
|
||||||
sinfo.send = make(chan []byte, 1024)
|
sinfo.send = make(chan []byte, 32)
|
||||||
sinfo.recv = make(chan *wire_trafficPacket, 1024)
|
sinfo.recv = make(chan *wire_trafficPacket, 32)
|
||||||
go sinfo.doWorker()
|
go sinfo.doWorker()
|
||||||
sinfo.time = time.Now()
|
sinfo.time = time.Now()
|
||||||
// Do some cleanup
|
// Do some cleanup
|
||||||
|
@ -128,13 +128,13 @@ func (iface *tcpInterface) handler(sock *net.TCPConn) {
|
|||||||
in := func(bs []byte) {
|
in := func(bs []byte) {
|
||||||
p.handlePacket(bs, linkIn)
|
p.handlePacket(bs, linkIn)
|
||||||
}
|
}
|
||||||
out := make(chan []byte, 1024) // TODO? what size makes sense
|
out := make(chan []byte, 32) // TODO? what size makes sense
|
||||||
defer close(out)
|
defer close(out)
|
||||||
go func() {
|
go func() {
|
||||||
var stack [][]byte
|
var stack [][]byte
|
||||||
put := func(msg []byte) {
|
put := func(msg []byte) {
|
||||||
stack = append(stack, msg)
|
stack = append(stack, msg)
|
||||||
for len(stack) > 1024 {
|
for len(stack) > 32 {
|
||||||
util_putBytes(stack[0])
|
util_putBytes(stack[0])
|
||||||
stack = stack[1:]
|
stack = stack[1:]
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ func (iface *udpInterface) handleKeys(msg []byte, addr connAddr) {
|
|||||||
peer: iface.core.peers.newPeer(&ks.box, &ks.sig),
|
peer: iface.core.peers.newPeer(&ks.box, &ks.sig),
|
||||||
linkIn: make(chan []byte, 1),
|
linkIn: make(chan []byte, 1),
|
||||||
keysIn: make(chan *udpKeys, 1),
|
keysIn: make(chan *udpKeys, 1),
|
||||||
out: make(chan []byte, 1024),
|
out: make(chan []byte, 32),
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
conn.in = func (msg []byte) { conn.peer.handlePacket(msg, conn.linkIn) }
|
conn.in = func (msg []byte) { conn.peer.handlePacket(msg, conn.linkIn) }
|
||||||
|
Loading…
Reference in New Issue
Block a user