Explorar o código

release buffer

Darien Raymond %!s(int64=8) %!d(string=hai) anos
pai
achega
02ce3ffded
Modificáronse 2 ficheiros con 4 adicións e 0 borrados
  1. 2 0
      common/crypto/auth.go
  2. 2 0
      proxy/shadowsocks/protocol.go

+ 2 - 0
common/crypto/auth.go

@@ -245,6 +245,8 @@ func (w *AuthenticationWriter) Write(b []byte) (int, error) {
 }
 
 func (w *AuthenticationWriter) WriteMultiBuffer(mb buf.MultiBuffer) (int, error) {
+	defer mb.Release()
+
 	const StartIndex = 17 * 1024
 	var totalBytes int
 	for {

+ 2 - 0
proxy/shadowsocks/protocol.go

@@ -385,6 +385,8 @@ type UDPWriter struct {
 }
 
 func (w *UDPWriter) Write(mb buf.MultiBuffer) error {
+	defer mb.Release()
+
 	for _, b := range mb {
 		if err := w.writeInternal(b); err != nil {
 			return err