This file is indexed.

/usr/share/gocode/src/bazil.org/fuse/fs/fstestutil/record/wait.go is in golang-bazil-fuse-dev 0.0~git20160811.0.371fbbd-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package record

import (
	"sync"
	"time"

	"bazil.org/fuse"
	"bazil.org/fuse/fs"
	"golang.org/x/net/context"
)

type nothing struct{}

// ReleaseWaiter notes whether a FUSE Release call has been seen.
//
// Releases are not guaranteed to happen synchronously with any client
// call, so they must be waited for.
type ReleaseWaiter struct {
	once sync.Once
	seen chan nothing
}

var _ = fs.HandleReleaser(&ReleaseWaiter{})

func (r *ReleaseWaiter) init() {
	r.once.Do(func() {
		r.seen = make(chan nothing, 1)
	})
}

func (r *ReleaseWaiter) Release(ctx context.Context, req *fuse.ReleaseRequest) error {
	r.init()
	close(r.seen)
	return nil
}

// WaitForRelease waits for Release to be called.
//
// With zero duration, wait forever. Otherwise, timeout early
// in a more controller way than `-test.timeout`.
//
// Returns whether a Release was seen. Always true if dur==0.
func (r *ReleaseWaiter) WaitForRelease(dur time.Duration) bool {
	r.init()
	var timeout <-chan time.Time
	if dur > 0 {
		timeout = time.After(dur)
	}
	select {
	case <-r.seen:
		return true
	case <-timeout:
		return false
	}
}