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
defer splice.Done(pair)
total := len(header) + fdData.Size()
if !pair.Grow(total) {
return fmt.Errorf("splice.Grow failed.")
if err := pair.Grow(total); err != nil {
return err
}
_, err = pair.Write(header)
......
package splice
import (
"fmt"
"os"
)
......@@ -10,27 +11,28 @@ type Pair struct {
}
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 {
return true
return nil
}
if !resizable {
return false
return fmt.Errorf("splice: want %d bytes, but not resizable", n)
}
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)
if errNo != 0 {
return false
return fmt.Errorf("splice: fcntl returned %v", errNo)
}
p.size = newsize
return true
return nil
}
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