Skip to content

Commit 72aa6a6

Browse files
authored
Merge pull request droyo#30 from seh-msft/rwalk_fix
Fix Rwalk() setting QIDs erroneously
2 parents 0320e6f + 6a41efc commit 72aa6a6

File tree

6 files changed

+21
-3
lines changed

6 files changed

+21
-3
lines changed

conn.go

+4
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ func (c *conn) qid(name string, qtype uint8) styxproto.Qid {
161161
return c.qidpool.Put(name, qtype)
162162
}
163163

164+
func (c *conn) getQid(name string, qtype uint8) (styxproto.Qid, bool) {
165+
return c.qidpool.Get(name)
166+
}
167+
164168
// All request contexts must have their cancel functions
165169
// called, to free up resources in the context. Returns false
166170
// if the tag is already cancelled

go.mod

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module aqwari.net/net/styx
2+
3+
go 1.16
4+
5+
require aqwari.net/retry v0.0.0-20180428204214-1281ce5d8df0

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
aqwari.net/retry v0.0.0-20180428204214-1281ce5d8df0 h1:BeD6U5TNwhMWxeydyi5xqpaNZx1MWl5QTcW4w7Mxf+Y=
2+
aqwari.net/retry v0.0.0-20180428204214-1281ce5d8df0/go.mod h1:XSNyyoM+OSg3vRmROPrS1lEpV7q/I9J1HAKMMxdUkU4=

internal/qidpool/pool.go

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func (p *Pool) Put(name string, qtype uint8) styxproto.Qid {
4242
m[name] = qid
4343
}
4444
})
45+
4546
p.m.Put(name, qid)
4647
return qid
4748
}

request.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package styx
22

33
import (
4+
"context"
45
"os"
56
"path"
67

7-
"context"
8-
98
"aqwari.net/net/styx/internal/styxfile"
109
"aqwari.net/net/styx/internal/sys"
1110
"aqwari.net/net/styx/styxproto"
@@ -266,6 +265,7 @@ func (t Tcreate) Rcreate(rwc interface{}, err error) {
266265
}
267266

268267
if dir, ok := rwc.(Directory); t.Mode.IsDir() && ok {
268+
269269
f = styxfile.NewDir(dir, path.Join(t.Path(), t.Name), t.session.conn.qidpool)
270270
} else {
271271
f, err = styxfile.New(rwc)

walk.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package styx
22

33
import (
4+
"errors"
45
"fmt"
56
"os"
67
"path"
@@ -180,7 +181,12 @@ func (t Twalk) Rwalk(info os.FileInfo, err error) {
180181
var mode os.FileMode
181182
if err == nil {
182183
mode = info.Mode()
183-
qid = t.session.conn.qid(t.Path(), styxfile.QidType(styxfile.Mode9P(mode)))
184+
fqid, found := t.session.conn.getQid(t.Path(), styxfile.QidType(styxfile.Mode9P(mode)))
185+
if !found {
186+
err = errors.New("rwalk did not find file")
187+
} else {
188+
qid = fqid
189+
}
184190
}
185191
t.walk.filled[t.index] = 1
186192
elem := walkElem{qid: qid, index: t.index, err: err}

0 commit comments

Comments
 (0)