Commit f4f9e240 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

splice: more verbose panic if discarding pipe pair fails

parent 6bca9f21
......@@ -6,6 +6,7 @@ package splice
import (
"fmt"
"log"
"os"
"syscall"
)
......@@ -43,6 +44,11 @@ func (p *Pair) discard() {
if err == syscall.EAGAIN {
// all good.
} else if err != nil {
panic(err)
errR := syscall.Close(p.r)
errW := syscall.Close(p.w)
// This can happen if something closed our fd
// inadvertently (eg. double close)
log.Panicf("splicing into /dev/null: %v (close R %d '%v', close W %d '%v')", err, p.r, errR, p.w, errW)
}
}
......@@ -94,7 +94,6 @@ func (pp *pairPool) get() (p *Pair, err error) {
func (pp *pairPool) done(p *Pair) {
p.discard()
pp.Lock()
pp.usedCount--
pp.unused = append(pp.unused, p)
......
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