lib9p

Go 9P library.
Log | Files | Refs

commit 071b093176846afbb759f0a70b051c1dfdeaa731
parent 16f75c0f938ca6770627985b54bfb64e5245bbaf
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Sun, 22 Oct 2023 08:11:44 +0900

change argument of *Client.transact()

Diffstat:
Mclient.go | 42+++++++++++++++---------------------------
1 file changed, 15 insertions(+), 27 deletions(-)

diff --git a/client.go b/client.go @@ -174,7 +174,8 @@ func (c *Client) runMultiplexer(ctx context.Context, tmsgc chan<- Msg, rmsgc <-c // Transact send 9P Msg of req to the multiplexer goroutines and recieves // the reply. -func (c *Client) transact(ctx context.Context, req *clientReq) (Msg, error) { +func (c *Client) transact(ctx context.Context, tmsg Msg) (Msg, error) { + req := newClientReq(ctx, tmsg) select { case <-ctx.Done(): return nil, ctx.Err() @@ -190,8 +191,7 @@ func (c *Client) transact(ctx context.Context, req *clientReq) (Msg, error) { func (c *Client) Version(ctx context.Context, tag uint16, mSize uint32, version string) (uint32, string, error) { tmsg := &TVersion{tag: tag, mSize: mSize, version: version} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return 0, "", fmt.Errorf("transact: %v", err) } @@ -207,8 +207,7 @@ func (c *Client) Version(ctx context.Context, tag uint16, mSize uint32, version func (c *Client) Auth(ctx context.Context, tag uint16, afid uint32, uname, aname string) (Qid, error) { tmsg := &TAuth{tag: tag, afid: afid, uname: uname} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return Qid{}, fmt.Errorf("transact: %v", err) } @@ -224,8 +223,7 @@ func (c *Client) Auth(ctx context.Context, tag uint16, afid uint32, uname, aname func (c *Client) Attach(ctx context.Context, tag uint16, fid, afid uint32, uname, aname string) (Qid, error) { tmsg := &TAttach{tag: tag, fid: fid, afid: afid, uname: uname, aname: aname} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return Qid{}, fmt.Errorf("transact: %v", err) } @@ -241,8 +239,7 @@ func (c *Client) Attach(ctx context.Context, tag uint16, fid, afid uint32, uname func (c *Client) Flush(ctx context.Context, tag, oldtag uint16) error { tmsg := &TFlush{tag: tag, oldtag: oldtag} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return fmt.Errorf("transact: %v", err) } @@ -257,8 +254,7 @@ func (c *Client) Flush(ctx context.Context, tag, oldtag uint16) error { } func (c *Client) Walk(ctx context.Context, tag uint16, fid, newFid uint32, wname []string) (wqid []Qid, err error) { tmsg := &TWalk{tag: tag, fid: fid, newFid: newFid, wname: wname} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return nil, fmt.Errorf("transact: %v", err) } @@ -273,8 +269,7 @@ func (c *Client) Walk(ctx context.Context, tag uint16, fid, newFid uint32, wname } func (c *Client) Open(ctx context.Context, tag uint16, fid uint32, mode OpenMode) (qid Qid, iounit uint32, err error) { tmsg := &TOpen{tag: tag, fid: fid, mode: mode} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return Qid{}, 0, fmt.Errorf("transact: %v", err) } @@ -289,8 +284,7 @@ func (c *Client) Open(ctx context.Context, tag uint16, fid uint32, mode OpenMode } func (c *Client) Create(ctx context.Context, tag uint16, fid uint32, name string, perm FileMode, mode OpenMode) (Qid, uint32, error) { tmsg := &TCreate{tag: tag, fid: fid, name: name, perm: perm, mode: mode} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return Qid{}, 0, fmt.Errorf("transact: %v", err) } @@ -305,8 +299,7 @@ func (c *Client) Create(ctx context.Context, tag uint16, fid uint32, name string } func (c *Client) Read(ctx context.Context, tag uint16, fid uint32, offset uint64, count uint32) (data []byte, err error) { tmsg := &TRead{tag: tag, fid: fid, offset: offset, count: count} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return nil, fmt.Errorf("transact: %v", err) } @@ -321,8 +314,7 @@ func (c *Client) Read(ctx context.Context, tag uint16, fid uint32, offset uint64 } func (c *Client) Write(ctx context.Context, tag uint16, fid uint32, offset uint64, count uint32, data []byte) (uint32, error) { tmsg := &TWrite{tag: tag, fid: fid, offset: offset, count: count, data: data} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return 0, fmt.Errorf("transact: %v", err) } @@ -337,8 +329,7 @@ func (c *Client) Write(ctx context.Context, tag uint16, fid uint32, offset uint6 } func (c *Client) Clunk(ctx context.Context, tag uint16, fid uint32) error { tmsg := &TClunk{tag: tag, fid: fid} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return fmt.Errorf("transact: %v", err) } @@ -353,8 +344,7 @@ func (c *Client) Clunk(ctx context.Context, tag uint16, fid uint32) error { } func (c *Client) Remove(ctx context.Context, tag uint16, fid uint32) error { tmsg := &TRemove{tag: tag, fid: fid} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return fmt.Errorf("transact: %v", err) } @@ -369,8 +359,7 @@ func (c *Client) Remove(ctx context.Context, tag uint16, fid uint32) error { } func (c *Client) Stat(ctx context.Context, tag uint16, fid uint32) (*Stat, error) { tmsg := &TStat{tag: tag, fid: fid} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return nil, fmt.Errorf("transact: %v", err) } @@ -385,8 +374,7 @@ func (c *Client) Stat(ctx context.Context, tag uint16, fid uint32) (*Stat, error } func (c *Client) Wstat(ctx context.Context, tag uint16, fid uint32, stat *Stat) error { tmsg := &TWStat{tag: tag, fid: fid, stat: stat} - req := newClientReq(ctx, tmsg) - rmsg, err := c.transact(ctx, req) + rmsg, err := c.transact(ctx, tmsg) if err != nil { return fmt.Errorf("transact: %v", err) }