Skip to content

Commit 10bef9f

Browse files
committed
add func to check if conn is closed
1 parent b0d09c4 commit 10bef9f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

conn/conn.go

+7
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ func (c *Conn) timeoutRequest(id uint32, timeout time.Duration) {
222222
place <- &result{err: ErrTimeout}
223223
}
224224

225+
// IsClosed returns if the connection is closed
226+
func (c *Conn) IsClosed() bool {
227+
c.mapMtx.Lock()
228+
defer c.mapMtx.Unlock()
229+
return c.closed
230+
}
231+
225232
// sendOp sends operation, returning a channel to wait for results
226233
func (c *Conn) sendOp(ctx context.Context, op protocol.Operation) (chan *result, error) {
227234
span, ctx := opentracing.StartSpanFromContext(ctx, "Conn.sendOp")

0 commit comments

Comments
 (0)