lib9p

Go 9P library.
Log | Files | Refs | LICENSE

commit 1ba9da1f4914f5a94fb1028a580201da68e9ab71
parent 7643de5da53a48e8235ef62d63d5c7f0007537bb
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Thu, 28 Dec 2023 08:24:42 +0900

fix bug where sAttach delets an fid when Tattach message
with the same fid arrives.

Diffstat:
Mserver.go | 18++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/server.go b/server.go @@ -279,12 +279,15 @@ func sAttach(ctx context.Context, s *Server, c <-chan *Req) { case <-ctx.Done(): return case r, ok := <-c: - var st fs.FileInfo + var ( + st fs.FileInfo + err error + ) if !ok { return } ifcall := r.Ifcall.(*TAttach) - fid, err := s.fPool.add(ifcall.Fid) + r.Fid, err = s.fPool.add(ifcall.Fid) if err != nil { r.err = ErrDupFid goto resp @@ -313,9 +316,9 @@ func sAttach(ctx context.Context, s *Server, c <-chan *Req) { goto resp } } - fid.OMode = -1 - fid.path = "." - fid.Uid = ifcall.Uname + r.Fid.OMode = -1 + r.Fid.path = "." + r.Fid.Uid = ifcall.Uname st, err = fs.Stat(ExportFS{s.fs}, ".") if err != nil { r.err = fmt.Errorf("stat root: %v", err) @@ -326,7 +329,9 @@ func sAttach(ctx context.Context, s *Server, c <-chan *Req) { } resp: if r.err != nil { - s.fPool.delete(r.Ifcall.(*TAttach).Fid) + if r.Fid != nil { + s.fPool.delete(r.Fid.Fid) + } setError(r, r.err) } s.respChan <- r @@ -1210,6 +1215,7 @@ func respond(ctx context.Context, s *Server) { if err != nil { log.Printf("speak: %v", err) } + r.Cancel() case <-ctx.Done(): return }