Skip to content

Commit 020171b

Browse files
committed
Check for closed pipe
1 parent 79991a9 commit 020171b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

enterprise/tailnet/coordinator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (c *haCoordinator) ServeClient(conn net.Conn, id uuid.UUID, agent uuid.UUID
121121
for {
122122
err := c.handleNextClientMessage(id, agent, decoder)
123123
if err != nil {
124-
if errors.Is(err, io.EOF) {
124+
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrClosedPipe) {
125125
return nil
126126
}
127127
return xerrors.Errorf("handle next client message: %w", err)
@@ -163,7 +163,7 @@ func (c *haCoordinator) handleNextClientMessage(id, agent uuid.UUID, decoder *js
163163

164164
_, err = agentSocket.Write(data)
165165
if err != nil {
166-
if errors.Is(err, io.EOF) {
166+
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrClosedPipe) {
167167
return nil
168168
}
169169
return xerrors.Errorf("write json: %w", err)
@@ -215,7 +215,7 @@ func (c *haCoordinator) ServeAgent(conn net.Conn, id uuid.UUID) error {
215215
for {
216216
node, err := c.handleAgentUpdate(id, decoder)
217217
if err != nil {
218-
if errors.Is(err, io.EOF) {
218+
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrClosedPipe) {
219219
return nil
220220
}
221221
return xerrors.Errorf("handle next agent message: %w", err)
@@ -471,7 +471,7 @@ func (c *haCoordinator) handlePubsubMessage(ctx context.Context, message []byte)
471471
// We get a single node over pubsub, so turn into an array.
472472
_, err = agentSocket.Write(nodeJSON)
473473
if err != nil {
474-
if errors.Is(err, io.EOF) {
474+
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrClosedPipe) {
475475
return
476476
}
477477
c.log.Error(ctx, "send callmemaybe to agent", slog.Error(err))

0 commit comments

Comments
 (0)