Skip to content

Commit 1d48e45

Browse files
committed
fix: 修复 switchServerAsync 在重连进行中导致的阻塞问题
1 parent 6792e63 commit 1d48e45

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

common/remote/rpc/rpc_client.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,13 @@ func (r *RpcClient) RegisterConnectionListener(listener IConnectionEventListener
407407
}
408408

409409
func (r *RpcClient) switchServerAsync(recommendServerInfo ServerInfo, onRequestFail bool) {
410-
r.reconnectionChan <- ReconnectContext{serverInfo: recommendServerInfo, onRequestFail: onRequestFail}
410+
select {
411+
case r.reconnectionChan <- ReconnectContext{serverInfo: recommendServerInfo, onRequestFail: onRequestFail}:
412+
// Reconnection request sent successfully
413+
default:
414+
// Channel is full, skip this request as reconnection is already in progress
415+
logger.Warnf("reconnection already in progress, skip this request")
416+
}
411417
}
412418

413419
func (r *RpcClient) reconnect(serverInfo ServerInfo, onRequestFail bool) {

0 commit comments

Comments
 (0)