Skip to content

Commit 4d79026

Browse files
committed
fix: prevent connIO from panicking in race between Close and Enqueue
1 parent 05d874f commit 4d79026

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

enterprise/tailnet/connio.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,8 @@ func (c *connIO) UniqueID() uuid.UUID {
197197
func (c *connIO) Enqueue(resp *proto.CoordinateResponse) error {
198198
atomic.StoreInt64(&c.lastWrite, time.Now().Unix())
199199
c.mu.Lock()
200-
closed := c.closed
201-
c.mu.Unlock()
202-
if closed {
200+
defer c.mu.Unlock()
201+
if c.closed {
203202
return xerrors.New("connIO closed")
204203
}
205204
select {

0 commit comments

Comments
 (0)