Skip to content

Commit 4baa712

Browse files
committed
Update written before check remain
Signed-off-by: Jim Ma <[email protected]>
1 parent e2854fd commit 4baa712

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

alg_linux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,14 @@ func (h *ihash) sendfile(f *os.File, remain int64) (written int64, err error, ha
205205
err = sc.Read(func(fd uintptr) bool {
206206
for {
207207
n, werr = syscall.Sendfile(h.s.FD(), int(fd), &offset, int(remain))
208+
written += int64(n)
208209
if werr != nil {
209210
break
210211
}
211212
if int64(n) >= remain {
212213
break
213214
}
214215
remain -= int64(n)
215-
written += int64(n)
216216
}
217217
return true
218218
})
@@ -301,6 +301,7 @@ type sysPipe struct {
301301
func (p *sysPipe) Splice(out, size, flags int) (int64, error) {
302302
return unix.Splice(p.fd, nil, out, nil, size, flags)
303303
}
304+
304305
func (p *sysPipe) Vmsplice(b []byte, flags int) (int, error) {
305306
iov := unix.Iovec{
306307
Base: &b[0],

0 commit comments

Comments
 (0)