diff --git a/bufferpool.go b/bufferpool.go index 2507ddf..487ac4a 100644 --- a/bufferpool.go +++ b/bufferpool.go @@ -50,6 +50,7 @@ func (bp *bufferPool) Get() []byte { // Put returns a buffer to the pool. func (bp *bufferPool) Put(buf []byte) { + // Only put back buffers of the correct size. if cap(buf) != mtuLimit { return } diff --git a/sess.go b/sess.go index 29247c3..3334921 100644 --- a/sess.go +++ b/sess.go @@ -292,7 +292,7 @@ RESET_TIMER: s.recvbuf = make([]byte, size) } - // resize the length of recvbuf to correspond to data size + // resize the length of recvbuf to match the data size s.recvbuf = s.recvbuf[:size] s.kcp.Recv(s.recvbuf) // read data to recvbuf first n = copy(b, s.recvbuf) // then copy bytes to 'b' as many as possible diff --git a/tx.go b/tx.go index ab5527e..9fe6e7b 100644 --- a/tx.go +++ b/tx.go @@ -29,7 +29,7 @@ import ( "golang.org/x/net/ipv4" ) -// defaultTx is the default procedure to transmit data +// defaultTx is the default transmission function for UDP sessions. func (s *UDPSession) defaultTx(txqueue []ipv4.Message) { nbytes := 0 npkts := 0 diff --git a/tx_linux.go b/tx_linux.go index 455a193..b3ba113 100644 --- a/tx_linux.go +++ b/tx_linux.go @@ -31,7 +31,8 @@ import ( "golang.org/x/net/ipv4" ) -// tx is the optimized procedure to transmit packets utilizing the linux sendmmsg system call +// tx is the optimized procedure to transmit packets utilizing +// batch write syscall on linux platform. func (s *UDPSession) tx(txqueue []ipv4.Message) { // default version if s.platform.batchConn == nil {