commit 4a336cff0cad66447d1a88b499fd9d112b7f4eed
parent 7a7f18f9bc9ba240e32963b4507c39d23ac3e78c
Author: Matsuda Kenji <info@mtkn.jp>
Date: Mon, 25 Dec 2023 19:30:44 +0900
set error when unknown type of message arrives
Diffstat:
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/server.go b/server.go
@@ -187,7 +187,7 @@ func (s *Server) getReq(ctx context.Context) *Req {
req.Cancel = cancel
req.Done = ctx.Done()
if ifcall, ok := req.Ifcall.(*TFlush); ok {
- req.Oldreq, _ = req.Srv.rPool.lookup(ifcall.Oldtag)
+ req.Oldreq, _ = s.rPool.lookup(ifcall.Oldtag)
}
if s.chatty9P {
fmt.Fprintf(os.Stderr, "<-- %v\n", req.Ifcall)
@@ -298,11 +298,10 @@ func sAttach(ctx context.Context, s *Server, c <-chan *Req) {
}
af, ok := afid.File.(*AuthFile)
if !ok {
- log.Printf("afile: %[1]T, %[1]v", afid.File)
r.err = fmt.Errorf("not auth file")
goto resp
}
- if !af.AuthOK {
+ if !af.AuthOK { // TODO: need to check Uname?
r.err = fmt.Errorf("not authenticated")
goto resp
}
@@ -1136,12 +1135,11 @@ L:
}
continue L
}
- go func() {
+ go func() { // TODO: is this worth a goroutine?
switch r.Ifcall.(type) {
default:
- r.err = fmt.Errorf("unknown message type: %d", r.Ifcall.Type())
+ setError(r, fmt.Errorf("unknown message type: %d", r.Ifcall.Type()))
s.respChan <- r
- return
case *TVersion:
versionChan <- r
case *TAuth: