summaryrefslogtreecommitdiffstats
path: root/beacon
diff options
context:
space:
mode:
authorJakob Borg <jakob@nym.se>2014-06-18 23:57:22 +0200
committerJakob Borg <jakob@nym.se>2014-06-19 01:02:32 +0200
commit4dbce32738ac610f8cabc8db2133580f31dbadee (patch)
tree2a21d7c2cf36bfb1d8940f9d035e1866a4253e96 /beacon
parentb05fcbc9d72dda356989bad150ada80b690bea64 (diff)
Simplify memory handling
Diffstat (limited to 'beacon')
-rw-r--r--beacon/beacon.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/beacon/beacon.go b/beacon/beacon.go
index 8ad7176117..f2bfd46a12 100644
--- a/beacon/beacon.go
+++ b/beacon/beacon.go
@@ -52,7 +52,7 @@ func (b *Beacon) Recv() ([]byte, net.Addr) {
}
func (b *Beacon) reader() {
- var bs = make([]byte, 65536)
+ bs := make([]byte, 65536)
for {
n, addr, err := b.conn.ReadFrom(bs)
if err != nil {
@@ -62,8 +62,11 @@ func (b *Beacon) reader() {
if debug {
l.Debugf("recv %d bytes from %s", n, addr)
}
+
+ c := make([]byte, n)
+ copy(c, bs)
select {
- case b.outbox <- recv{bs[:n], addr}:
+ case b.outbox <- recv{c, addr}:
default:
if debug {
l.Debugln("dropping message")