diff options
author | Jakob Unterwurzacher | 2019-01-03 15:38:51 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2019-01-03 15:38:51 +0100 |
commit | bb9884549bab29e73dd0a7cb98ed7e8422796306 (patch) | |
tree | a85bd1b6552793a42c6761a029902cbec84333cc /tests/test_helpers | |
parent | 4f66d66755da63c78b09201c6c72353009251cf2 (diff) |
tests: allow one extra fd in fd leak detector (dirCache)
The gocryptfs process may keep one fd open for up to one second
in the dirCache.
Diffstat (limited to 'tests/test_helpers')
-rw-r--r-- | tests/test_helpers/mount_unmount.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/test_helpers/mount_unmount.go b/tests/test_helpers/mount_unmount.go index 8ba96ec..39f7c77 100644 --- a/tests/test_helpers/mount_unmount.go +++ b/tests/test_helpers/mount_unmount.go @@ -122,6 +122,9 @@ func UnmountPanic(dir string) { } } +// gocryptfs may hold up to maxCacheFds open for caching +const maxCacheFds = 1 + // UnmountErr tries to unmount "dir", retrying 10 times, and returns the // resulting error. func UnmountErr(dir string) (err error) { @@ -146,7 +149,7 @@ func UnmountErr(dir string) (err error) { // hope that all close commands get through to the gocryptfs // process. fdsNow = ListFds(pid) - if len(fdsNow) <= len(fds) { + if len(fdsNow) <= len(fds)+maxCacheFds { break } fmt.Printf("UnmountErr: fdsOld=%d fdsNow=%d, retrying\n", len(fds), len(fdsNow)) @@ -159,7 +162,7 @@ func UnmountErr(dir string) (err error) { cmd.Stderr = os.Stderr err = cmd.Run() if err == nil { - if len(fdsNow) > len(fds) { + if len(fdsNow) > len(fds)+maxCacheFds { return fmt.Errorf("FD leak? pid=%d dir=%q, fds:\nold=%v \nnew=%v\n", pid, dir, fds, fdsNow) } return nil |