@@ -27,10 +27,10 @@ func InMemHandler() Handlers {
27
27
28
28
// Example Handlers
29
29
func (fs * root ) Fileread (r * Request ) (io.ReaderAt , error ) {
30
- _ = r .WithContext (r .Context ())
31
30
if fs .mockErr != nil {
32
31
return nil , fs .mockErr
33
32
}
33
+ _ = r .WithContext (r .Context ()) // initialize context for deadlock testing
34
34
fs .filesLock .Lock ()
35
35
defer fs .filesLock .Unlock ()
36
36
file , err := fs .fetch (r .Filepath )
@@ -47,10 +47,10 @@ func (fs *root) Fileread(r *Request) (io.ReaderAt, error) {
47
47
}
48
48
49
49
func (fs * root ) Filewrite (r * Request ) (io.WriterAt , error ) {
50
- _ = r .WithContext (r .Context ())
51
50
if fs .mockErr != nil {
52
51
return nil , fs .mockErr
53
52
}
53
+ _ = r .WithContext (r .Context ()) // initialize context for deadlock testing
54
54
fs .filesLock .Lock ()
55
55
defer fs .filesLock .Unlock ()
56
56
file , err := fs .fetch (r .Filepath )
@@ -69,10 +69,10 @@ func (fs *root) Filewrite(r *Request) (io.WriterAt, error) {
69
69
}
70
70
71
71
func (fs * root ) Filecmd (r * Request ) error {
72
- _ = r .WithContext (r .Context ())
73
72
if fs .mockErr != nil {
74
73
return fs .mockErr
75
74
}
75
+ _ = r .WithContext (r .Context ()) // initialize context for deadlock testing
76
76
fs .filesLock .Lock ()
77
77
defer fs .filesLock .Unlock ()
78
78
switch r .Method {
@@ -130,10 +130,10 @@ func (f listerat) ListAt(ls []os.FileInfo, offset int64) (int, error) {
130
130
}
131
131
132
132
func (fs * root ) Filelist (r * Request ) (ListerAt , error ) {
133
- _ = r .WithContext (r .Context ())
134
133
if fs .mockErr != nil {
135
134
return nil , fs .mockErr
136
135
}
136
+ _ = r .WithContext (r .Context ()) // initialize context for deadlock testing
137
137
fs .filesLock .Lock ()
138
138
defer fs .filesLock .Unlock ()
139
139
0 commit comments