commit 164ffe8157d4eda7cc45b80f5b6f63be47f8855b
parent c140dfd37336705a9b79a4e75ceaf9380a8ce6dd
Author: Matsuda Kenji <info@mtkn.jp>
Date: Mon, 25 Dec 2023 10:01:02 +0900
fix bug where respond goroutine returns
Diffstat:
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/auth_test.go b/auth_test.go
@@ -21,14 +21,14 @@ func TestAuth(t *testing.T) {
asw.Close()
}()
conn.S.Auth = func(ctx context.Context, respc chan<- *lib9p.Req) chan<- *lib9p.Req {
- c := make(chan *lib9p.Req)
+ authc := make(chan *lib9p.Req)
go func() {
for {
select {
case <-ctx.Done():
return
- case r := <-c:
- if r == nil {
+ case r, ok := <-authc:
+ if !ok {
return
}
ifcall := r.Ifcall.(*lib9p.TAuth)
@@ -46,7 +46,7 @@ func TestAuth(t *testing.T) {
}
}
}()
- return c
+ return authc
}
ctx := context.Background()
_, _, err := conn.C.Version(ctx, lib9p.NOTAG, 8*1024, "9P2000")
diff --git a/server.go b/server.go
@@ -1440,11 +1440,6 @@ func respond(ctx context.Context, s *Server) {
}
select {
case err := <-r.speakErrChan:
- select {
- case <-ctx.Done():
- return
- default:
- }
// TODO: handle errors.
if err != nil {
log.Printf("speak: %v", err)