Stenographer is a packet capture solution which aims to quickly spool all packets to disk, then provide simple, fast access to subsets of those packets. Discussion/announcements at stenographer@googlegroups.com
Hi,
I was trying to track down an issue that when the disk usage exceeded limit, the stenographer removes all cache file instead of enough just to be below the limit. Strace show that the actual syscall of close() is about two minutes after the unlink of the file. During the two minutes, stenographer makes repeated attempts to remove more files and eventually deleted all of the cache.
Found the last function in filecache.go, the cf.f is set to nil before Close. I have never coded in go, but this looks unusual. Changes the code to
Hi, I was trying to track down an issue that when the disk usage exceeded limit, the stenographer removes all cache file instead of enough just to be below the limit. Strace show that the actual syscall of close() is about two minutes after the unlink of the file. During the two minutes, stenographer makes repeated attempts to remove more files and eventually deleted all of the cache.
Found the last function in filecache.go, the cf.f is set to nil before Close. I have never coded in go, but this looks unusual. Changes the code to
func (cf *CachedFile) closeFile() error { if cf.f == nil { v(3, "Close of already-closed file %q ignored", cf.filename) return nil } v(2, "Closing %q", cf.filename) cf.cache.opened-- defer cf.nilFile() return cf.f.Close() }
func (cf *CachedFile) nilFile() { cf.f = nil }
The problem is gone.
Ming