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

Commit56ca7ac

Browse files
committed
Fix incorrect logger context on reconnecting PTY
Since we used the same var all I did with my other change was use thesame logger anyway.Now it will not have the connection ID, which is correct since thepty is not tied to a single connection.
1 parent7a8ec2e commit56ca7ac

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

‎agent/agent.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,8 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
10711071
defera.connCountReconnectingPTY.Add(-1)
10721072

10731073
connectionID:=uuid.NewString()
1074-
logger=logger.With(slog.F("message_id",msg.ID),slog.F("connection_id",connectionID))
1075-
logger.Debug(ctx,"starting handler")
1074+
connLogger:=logger.With(slog.F("message_id",msg.ID),slog.F("connection_id",connectionID))
1075+
connLogger.Debug(ctx,"starting handler")
10761076

10771077
deferfunc() {
10781078
iferr:=retErr;err!=nil {
@@ -1083,12 +1083,12 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
10831083
// If the agent is closed, we don't want to
10841084
// log this as an error since it's expected.
10851085
ifclosed {
1086-
logger.Debug(ctx,"reconnecting pty failed with attach error (agent closed)",slog.Error(err))
1086+
connLogger.Debug(ctx,"reconnecting pty failed with attach error (agent closed)",slog.Error(err))
10871087
}else {
1088-
logger.Error(ctx,"reconnecting pty failed with attach error",slog.Error(err))
1088+
connLogger.Error(ctx,"reconnecting pty failed with attach error",slog.Error(err))
10891089
}
10901090
}
1091-
logger.Debug(ctx,"reconnecting pty connection closed")
1091+
connLogger.Debug(ctx,"reconnecting pty connection closed")
10921092
}()
10931093

10941094
varrpty reconnectingpty.ReconnectingPTY
@@ -1097,7 +1097,7 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
10971097
waitReady,ok:=a.reconnectingPTYs.LoadOrStore(msg.ID,sendConnected)
10981098
ifok {
10991099
close(sendConnected)// Unused.
1100-
logger.Debug(ctx,"connecting to existing reconnecting pty")
1100+
connLogger.Debug(ctx,"connecting to existing reconnecting pty")
11011101
c,ok:=waitReady.(chan reconnectingpty.ReconnectingPTY)
11021102
if!ok {
11031103
returnxerrors.Errorf("found invalid type in reconnecting pty map: %T",waitReady)
@@ -1108,7 +1108,7 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
11081108
}
11091109
c<-rpty// Put it back for the next reconnect.
11101110
}else {
1111-
logger.Debug(ctx,"creating new reconnecting pty")
1111+
connLogger.Debug(ctx,"creating new reconnecting pty")
11121112

11131113
connected:=false
11141114
deferfunc() {
@@ -1141,7 +1141,7 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
11411141
connected=true
11421142
sendConnected<-rpty
11431143
}
1144-
returnrpty.Attach(ctx,connectionID,conn,msg.Height,msg.Width,logger)
1144+
returnrpty.Attach(ctx,connectionID,conn,msg.Height,msg.Width,connLogger)
11451145
}
11461146

11471147
// startReportingConnectionStats runs the connection stats reporting goroutine.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp