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

Commit3f8c815

Browse files
committed
fix: wsNetConn cancel on any error
1 parentef439fe commit3f8c815

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"
@@ -510,23 +509,23 @@ func convertWorkspaceAgent(dbAgent database.WorkspaceAgent, agentUpdateFrequency
510509
}
511510

512511
// wsNetConn wraps net.Conn created by websocket.NetConn(). Cancel func
513-
// is called ifio.EOF is encountered.
512+
// is called ifa read or write error is encountered.
514513
typewsNetConnstruct {
515514
cancel context.CancelFunc
516515
net.Conn
517516
}
518517

519518
func (c*wsNetConn)Read(b []byte) (nint,errerror) {
520519
n,err=c.Conn.Read(b)
521-
iferrors.Is(err,io.EOF) {
520+
iferr!=nil {
522521
c.cancel()
523522
}
524523
returnn,err
525524
}
526525

527526
func (c*wsNetConn)Write(b []byte) (nint,errerror) {
528527
n,err=c.Conn.Write(b)
529-
iferrors.Is(err,io.EOF) {
528+
iferr!=nil {
530529
c.cancel()
531530
}
532531
returnn,err
@@ -538,8 +537,8 @@ func (c *wsNetConn) Close() error {
538537
}
539538

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp