1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-25 21:36:13 -04:00

revert opt on copy

This commit is contained in:
Darien Raymond 2018-11-15 21:16:54 +01:00
parent bd7bc63fac
commit a5ed9e00ab
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -3,7 +3,6 @@ package buf
import (
"io"
"time"
"unsafe"
"v2ray.com/core/common/errors"
"v2ray.com/core/common/signal"
@ -11,7 +10,6 @@ import (
type dataHandler func(MultiBuffer)
//go:notinheap
type copyHandler struct {
onData []dataHandler
}
@ -98,13 +96,10 @@ func copyInternal(reader Reader, writer Writer, handler *copyHandler) error {
// Copy dumps all payload from reader to writer or stops when an error occurs. It returns nil when EOF.
func Copy(reader Reader, writer Writer, options ...CopyOption) error {
var handler copyHandler
p := uintptr(unsafe.Pointer(&handler))
h := (*copyHandler)(unsafe.Pointer(p))
for _, option := range options {
option(h)
option(&handler)
}
err := copyInternal(reader, writer, h)
err := copyInternal(reader, writer, &handler)
if err != nil && errors.Cause(err) != io.EOF {
return err
}