浏览代码

restrict multi-writer to syscall.conn only

Darien Raymond 7 年之前
父节点
当前提交
f27a381fe8
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      common/buf/io.go

+ 7 - 0
common/buf/io.go

@@ -79,6 +79,13 @@ func NewWriter(writer io.Writer) Writer {
 		return mw
 	}
 
+	if _, ok := writer.(syscall.Conn); !ok {
+		// If the writer doesn't implement syscall.Conn, it is probably not a TCP connection.
+		return &SequentialWriter{
+			Writer: writer,
+		}
+	}
+
 	return &BufferToBytesWriter{
 		Writer: writer,
 	}