tracker/udp/conn-client.go | 2 +- tracker/udp/dispatcher.go | 3 ++- diff --git a/tracker/udp/conn-client.go b/tracker/udp/conn-client.go index d7e19027a8a9aac8e3d4a4fb788ebf2139ff4872..d789cc3bde643934b93f041fd587abbf91564474 100644 --- a/tracker/udp/conn-client.go +++ b/tracker/udp/conn-client.go @@ -23,8 +23,8 @@ ipv6 bool } func (cc *ConnClient) reader() { + b := make([]byte, 0x800) for { - b := make([]byte, 0x800) n, err := cc.conn.Read(b) if err != nil { // TODO: Do bad things to the dispatcher, and incoming calls to the client if we have a diff --git a/tracker/udp/dispatcher.go b/tracker/udp/dispatcher.go index 907eb15b1e60633a4d1f351f75baafba76fa8119..3aad927e3848bfb5cbe742cd1c294ea4b6e9790a 100644 --- a/tracker/udp/dispatcher.go +++ b/tracker/udp/dispatcher.go @@ -11,6 +11,7 @@ mu sync.RWMutex transactions map[TransactionId]Transaction } +// The caller owns b. func (me *Dispatcher) Dispatch(b []byte) error { buf := bytes.NewBuffer(b) var rh ResponseHeader @@ -23,7 +24,7 @@ defer me.mu.RUnlock() if t, ok := me.transactions[rh.TransactionId]; ok { t.h(DispatchedResponse{ Header: rh, - Body: buf.Bytes(), + Body: append([]byte(nil), buf.Bytes()...), }) return nil } else {