Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ func (c *conn) qid(name string, qtype uint8) styxproto.Qid {
return c.qidpool.Put(name, qtype)
}

func (c *conn) getQid(name string, qtype uint8) (styxproto.Qid, bool) {
return c.qidpool.Get(name)
}

// All request contexts must have their cancel functions
// called, to free up resources in the context. Returns false
// if the tag is already cancelled
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module aqwari.net/net/styx

go 1.16
go 1.19

require aqwari.net/retry v0.0.0-20180428204214-1281ce5d8df0
2 changes: 0 additions & 2 deletions internal/qidpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ func (p *Pool) Put(name string, qtype uint8) styxproto.Qid {
m[name] = qid
}
})

p.m.Put(name, qid)
return qid
}

Expand Down
4 changes: 2 additions & 2 deletions request.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package styx

import (
"context"
"os"
"path"

"context"

"aqwari.net/net/styx/internal/styxfile"
"aqwari.net/net/styx/internal/sys"
"aqwari.net/net/styx/styxproto"
Expand Down Expand Up @@ -265,7 +266,6 @@ func (t Tcreate) Rcreate(rwc interface{}, err error) {
}

if dir, ok := rwc.(Directory); t.Mode.IsDir() && ok {

f = styxfile.NewDir(dir, path.Join(t.Path(), t.Name), t.session.conn.qidpool)
} else {
f, err = styxfile.New(rwc)
Expand Down
28 changes: 28 additions & 0 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,34 @@ func TestWalk(t *testing.T) {
}
}

func TestWalkNonexistent(t *testing.T) {
srv := testServer{test: t}
srv.callback = func(req, rsp styxproto.Msg) {
if _, ok := req.(styxproto.Twalk); ok {
if _, ok := rsp.(styxproto.Rerror); !ok {
t.Errorf("expected Rerror response to nonexistent Twalk, instead got: %T", rsp)
}
}
}
srv.handler = HandlerFunc(func(s *Session) {
for s.Next() {
switch req := s.Request().(type) {
case Twalk:
t.Logf("Twalk %s", req.Path())
req.Rwalk(nil, errors.New("not found"))
// If the walk resulted in an error, then no Qid should have been created for this path
if _, ok := s.conn.qidpool.Get(req.Path()); ok {
t.Error("qid was created when it shouldn't have been")
}
}
}
})

srv.runMsg(func(enc *styxproto.Encoder) {
enc.Twalk(1, 0, 1, "nonexistent")
})
}

func blankQid() styxproto.Qid {
buf := make([]byte, styxproto.QidLen)
qid, _, err := styxproto.NewQid(buf, 0, 0, 0)
Expand Down
8 changes: 1 addition & 7 deletions walk.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package styx

import (
"errors"
"fmt"
"os"
"path"
Expand Down Expand Up @@ -181,12 +180,7 @@ func (t Twalk) Rwalk(info os.FileInfo, err error) {
var mode os.FileMode
if err == nil {
mode = info.Mode()
fqid, found := t.session.conn.getQid(t.Path(), styxfile.QidType(styxfile.Mode9P(mode)))
if !found {
err = errors.New("rwalk did not find file")
} else {
qid = fqid
}
qid = t.session.conn.qid(t.Path(), styxfile.QidType(styxfile.Mode9P(mode)))
}
t.walk.filled[t.index] = 1
elem := walkElem{qid: qid, index: t.index, err: err}
Expand Down