commit 649cfd65e5ebf86946766b0334bb3f41ace89a3e
parent 93a84303125862c26d5bd350051a1faf918fa1aa
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 20 Dec 2023 15:40:53 +0900
delete completed TODOs
Diffstat:
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/server.go b/server.go
@@ -64,7 +64,8 @@ type Server struct {
// Auth is called when Tauth message arrives.
// If authentication is desired, the Auth functions should
- // set Req.Afid.Qid and Req.Ofcall.Qid.
+ // set Req.Afid.File to an *AuthFile and Req.Ofcall.Qid, and prepare to
+ // authenticate via the Read()/Write() calls to Req.Afid.File
// If this is nil, no authentication is performed.
Auth func(context.Context, *Req)
}
@@ -105,8 +106,6 @@ func (s *Server) setMSize(mSize uint32) {
// Listener goroutine reads 9P messages from r and allocats Req for each
// of them, and sends it to the returned chan of *Req.
// It reports any error to the returned chan of error.
-// TODO: pass context.Context and stop the goroutine with the Context being
-// canceled.
func (s *Server) runListener(ctx context.Context) {
rc := make(chan *Req)
s.listenChan = rc
@@ -125,8 +124,6 @@ func (s *Server) runListener(ctx context.Context) {
// runSpeaker runs the speaker goroutine.
// Speaker goroutine wait for reply Requests from the returned channel,
// and marshalls each of them into 9P messages and writes it to w.
-// TODO: pass context.Context and stop the goroutine with the Context being
-// canceled.
func (s *Server) runSpeaker(ctx context.Context) {
rc := make(chan *Req)
s.speakChan = rc
@@ -186,7 +183,7 @@ func getReq(r io.Reader, s *Server) *Req {
return req
}
-// sVersion processes Tversion message.
+// sVersion processes Tversion messages.
// It checks if the version string is "9P2000", and if the version differs from
// that, it replies with version string "unknown".
// It also checks the msize of the message and if it is bigger than that of the
@@ -409,7 +406,8 @@ func sOpen(ctx context.Context, s *Server, r *Req) {
st fs.FileInfo
)
if afile, ok := r.Fid.File.(*AuthFile); ok {
- // TODO: r.Fid.File should not be nil.
+ // s.Auth should set r.Fid.File to a valid *AuthFile,
+ // so r.Fid.File should not be nil.
st, err = r.Fid.File.Stat()
if err != nil {
Respond(ctx, r, fmt.Errorf("stat: %v", err))
@@ -553,6 +551,7 @@ func rCreate(r *Req, err error) {
}
}
+// TODO: I think the file should be locked while reading.
func sRead(ctx context.Context, s *Server, r *Req) {
ifcall := r.Ifcall.(*TRead)
var ok bool
@@ -648,7 +647,7 @@ func rRead(r *Req, err error) {
}
}
-// TODO: file can be created with ORDWR but without write permission.
+// TODO: I think the file should be locked while reading.
func sWrite(ctx context.Context, s *Server, r *Req) {
ifcall := r.Ifcall.(*TWrite)
var ok bool
@@ -707,7 +706,6 @@ func rWrite(r *Req, err error) {
setError(r, err)
return
}
- // TODO: Increment Qid.Vers
}
func sClunk(ctx context.Context, s *Server, r *Req) {