Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9e6727e

Browse files
committed
fix: wsNetConn cancel on any error
1 parente0a2f8e commit9e6727e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

‎coderd/workspaceagents.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"database/sql"
66
"encoding/json"
7-
"errors"
87
"fmt"
98
"io"
109
"net"
@@ -521,23 +520,23 @@ func convertWorkspaceAgent(dbAgent database.WorkspaceAgent, agentUpdateFrequency
521520
}
522521

523522
// wsNetConn wraps net.Conn created by websocket.NetConn(). Cancel func
524-
// is called ifio.EOF is encountered.
523+
// is called ifa read or write error is encountered.
525524
typewsNetConnstruct {
526525
cancel context.CancelFunc
527526
net.Conn
528527
}
529528

530529
func (c*wsNetConn)Read(b []byte) (nint,errerror) {
531530
n,err=c.Conn.Read(b)
532-
iferrors.Is(err,io.EOF) {
531+
iferr!=nil {
533532
c.cancel()
534533
}
535534
returnn,err
536535
}
537536

538537
func (c*wsNetConn)Write(b []byte) (nint,errerror) {
539538
n,err=c.Conn.Write(b)
540-
iferrors.Is(err,io.EOF) {
539+
iferr!=nil {
541540
c.cancel()
542541
}
543542
returnn,err
@@ -549,8 +548,8 @@ func (c *wsNetConn) Close() error {
549548
}
550549

551550
// websocketNetConn wraps websocket.NetConn and returns a context that
552-
// is tied to the parent context and the lifetime of the conn.A io.EOF
553-
//errorduring read or write will cancel the context, but not close the
551+
// is tied to the parent context and the lifetime of the conn.Any error
552+
// during read or write will cancel the context, but not close the
554553
// conn. Close should be called to release context resources.
555554
funcwebsocketNetConn(ctx context.Context,conn*websocket.Conn,msgType websocket.MessageType) (context.Context, net.Conn) {
556555
ctx,cancel:=context.WithCancel(ctx)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp