Skip to content

Commit 37c6957

Browse files
rataipochi
authored andcommitted
konn-client: Simplify DATA case
Instead of having all the code inside an if, and outside just a log for the "uninteresting" case, let's just check if the conection is not recognize and remove the identation for the rest. There is no behavior change, this change is cosmetical. Signed-off-by: Rodrigo Campos <[email protected]>
1 parent 02e25c4 commit 37c6957

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

konnectivity-client/pkg/client/client.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -281,19 +281,19 @@ func (t *grpcTunnel) serve(tunnelCtx context.Context) {
281281
// TODO: flow control
282282
conn, ok := t.conns.get(resp.ConnectID)
283283

284-
if ok {
285-
timer := time.NewTimer((time.Duration)(t.readTimeoutSeconds) * time.Second)
286-
select {
287-
case conn.readCh <- resp.Data:
288-
timer.Stop()
289-
case <-timer.C:
290-
klog.ErrorS(fmt.Errorf("timeout"), "readTimeout has been reached, the grpc connection to the proxy server will be closed", "connectionID", conn.connID, "readTimeoutSeconds", t.readTimeoutSeconds)
291-
return
292-
case <-tunnelCtx.Done():
293-
klog.V(1).InfoS("Tunnel has been closed, the grpc connection to the proxy server will be closed", "connectionID", conn.connID)
294-
}
295-
} else {
296-
klog.V(1).InfoS("connection not recognized", "connectionID", resp.ConnectID)
284+
if !ok {
285+
klog.V(1).InfoS("Connection not recognized", "connectionID", resp.ConnectID)
286+
continue
287+
}
288+
timer := time.NewTimer((time.Duration)(t.readTimeoutSeconds) * time.Second)
289+
select {
290+
case conn.readCh <- resp.Data:
291+
timer.Stop()
292+
case <-timer.C:
293+
klog.ErrorS(fmt.Errorf("timeout"), "readTimeout has been reached, the grpc connection to the proxy server will be closed", "connectionID", conn.connID, "readTimeoutSeconds", t.readTimeoutSeconds)
294+
return
295+
case <-tunnelCtx.Done():
296+
klog.V(1).InfoS("Tunnel has been closed, the grpc connection to the proxy server will be closed", "connectionID", conn.connID)
297297
}
298298

299299
case client.PacketType_CLOSE_RSP:

0 commit comments

Comments
 (0)