commit d0c004a01a055f7d1cb944f0044a84b23807dcec
parent 67a61a4c20d983e067db6f8cb3d12f4c4c5cf3cc
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 20 Dec 2023 08:50:56 +0900
release all blocking reads when the file is removed
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/cmd/semfs/fs.go b/cmd/semfs/fs.go
@@ -10,7 +10,6 @@ import (
"time"
"git.mtkn.jp/lib9p"
- "log"
)
type semFS struct {
@@ -145,6 +144,9 @@ func (f *semFile) start(ctx context.Context) {
for {
select {
case <-ctx.Done():
+ for _, c := range f.queue {
+ close(c)
+ }
return
case c := <-rchan:
if c == nil {
@@ -190,7 +192,6 @@ func (f *semFile) Close() error {
func (f *semFile) Read(p []byte) (n int, err error) {
if len(p) > 0 {
- log.Println("chan")
c := make(chan struct{})
f.rchan <- c
<-c