Skip to content

Commit 2ab7944

Browse files
committed
Optimizing internal rpc
1 parent 2f91a11 commit 2ab7944

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

internal/transporter/internal/client/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func NewClient(opts *Options) *Client {
3737
c.opts = opts
3838
c.connections = make([]*Conn, 0, defaultConnNum)
3939
c.disorderlyQueue = make(chan *chWrite, 10240)
40+
c.closed.Store(true)
4041
c.pool = sync.Pool{New: func() any { return &chWrite{} }}
4142

4243
return c
@@ -74,6 +75,8 @@ func (c *Client) Establish() error {
7475
return err
7576
}
7677

78+
c.closed.Store(false)
79+
7780
return nil
7881
}
7982

internal/transporter/internal/client/conn.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ func (c *Conn) handshake(conn net.Conn) error {
127127

128128
c.pending.store(seq, call)
129129

130-
defer close(call)
131-
132130
if _, err := conn.Write(buf.Bytes()); err != nil {
131+
close(call)
132+
133133
c.pending.delete(seq)
134+
134135
return err
135136
}
136137

0 commit comments

Comments
 (0)