Commit 035be141 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Add outstanding number of pipes to debug output.

parent 6a9ca360
...@@ -21,6 +21,10 @@ func Get() (*Pair, error) { ...@@ -21,6 +21,10 @@ func Get() (*Pair, error) {
return splicePool.get() return splicePool.get()
} }
func Total() int {
return splicePool.total()
}
func Used() int { func Used() int {
return splicePool.used() return splicePool.used()
} }
...@@ -35,17 +39,26 @@ func newSplicePairPool() *pairPool { ...@@ -35,17 +39,26 @@ func newSplicePairPool() *pairPool {
func (me *pairPool) clear() { func (me *pairPool) clear() {
me.Lock() me.Lock()
defer me.Unlock()
for _, p := range me.unused { for _, p := range me.unused {
p.Close() p.Close()
} }
me.unused = me.unused[:0] me.unused = me.unused[:0]
me.Unlock()
} }
func (me *pairPool) used() int { func (me *pairPool) used() (n int) {
me.Lock() me.Lock()
defer me.Unlock() n = me.usedCount
return me.usedCount me.Unlock()
return n
}
func (me *pairPool) total() int {
me.Lock()
n := me.usedCount + len(me.unused)
me.Unlock()
return n
} }
func (me *pairPool) get() (p *Pair, err error) { func (me *pairPool) get() (p *Pair, err error) {
...@@ -79,9 +92,9 @@ func (me *pairPool) done(p *Pair) { ...@@ -79,9 +92,9 @@ func (me *pairPool) done(p *Pair) {
DiscardAll(p.r) DiscardAll(p.r)
me.Lock() me.Lock()
defer me.Unlock()
me.usedCount-- me.usedCount--
me.unused = append(me.unused, p) me.unused = append(me.unused, p)
me.Unlock()
} }
func init() { func init() {
......
...@@ -3,6 +3,7 @@ package unionfs ...@@ -3,6 +3,7 @@ package unionfs
import ( import (
"fmt" "fmt"
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/splice"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
...@@ -373,6 +374,10 @@ func (fs *AutoUnionFs) DebugData() string { ...@@ -373,6 +374,10 @@ func (fs *AutoUnionFs) DebugData() string {
if fs.connector != nil { if fs.connector != nil {
msg += fmt.Sprintf("Live inodes: %d\n", fs.connector.InodeHandleCount()) msg += fmt.Sprintf("Live inodes: %d\n", fs.connector.InodeHandleCount())
} }
pairs := splice.Total()
if pairs > 0 {
msg += fmt.Sprintf("Pipes: %d\n", pairs)
}
return msg return msg
} }
......
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