Commit 90e49967 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Make splice errors more verbose.

parent fa265b73
...@@ -24,8 +24,8 @@ func (ms *MountState) trySplice(header []byte, req *request, fdData *ReadResultF ...@@ -24,8 +24,8 @@ func (ms *MountState) trySplice(header []byte, req *request, fdData *ReadResultF
defer splice.Done(pair) defer splice.Done(pair)
total := len(header) + fdData.Size() total := len(header) + fdData.Size()
if !pair.Grow(total) { if err := pair.Grow(total); err != nil {
return fmt.Errorf("splice.Grow failed.") return err
} }
_, err = pair.Write(header) _, err = pair.Write(header)
......
package splice package splice
import ( import (
"fmt"
"os" "os"
) )
...@@ -10,27 +11,28 @@ type Pair struct { ...@@ -10,27 +11,28 @@ type Pair struct {
} }
func (p *Pair) MaxGrow() { func (p *Pair) MaxGrow() {
for p.Grow(2 * p.size) { for p.Grow(2 * p.size) == nil {
} }
} }
func (p *Pair) Grow(n int) bool {
func (p *Pair) Grow(n int) error {
if n <= p.size { if n <= p.size {
return true return nil
} }
if !resizable { if !resizable {
return false return fmt.Errorf("splice: want %d bytes, but not resizable", n)
} }
if n > maxPipeSize { if n > maxPipeSize {
return false return fmt.Errorf("splice: want %d bytes, max pipe size %d", n, maxPipeSize)
} }
newsize, errNo := fcntl(p.r.Fd(), F_SETPIPE_SZ, n) newsize, errNo := fcntl(p.r.Fd(), F_SETPIPE_SZ, n)
if errNo != 0 { if errNo != 0 {
return false return fmt.Errorf("splice: fcntl returned %v", errNo)
} }
p.size = newsize p.size = newsize
return true return nil
} }
func (p *Pair) Cap() int { func (p *Pair) Cap() int {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment