Skip to content

Commit

Permalink
konn-client: Simplify DATA case
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rata authored and ipochi committed Sep 8, 2022
1 parent 27d7b21 commit a861c24
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions konnectivity-client/pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,19 +280,19 @@ func (t *grpcTunnel) serve(tunnelCtx context.Context) {
// TODO: flow control
conn, ok := t.conns.get(resp.ConnectID)

if ok {
timer := time.NewTimer((time.Duration)(t.readTimeoutSeconds) * time.Second)
select {
case conn.readCh <- resp.Data:
timer.Stop()
case <-timer.C:
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)
return
case <-tunnelCtx.Done():
klog.V(1).InfoS("Tunnel has been closed, the grpc connection to the proxy server will be closed", "connectionID", conn.connID)
}
} else {
if !ok {
klog.V(1).InfoS("connection not recognized", "connectionID", resp.ConnectID)
continue
}
timer := time.NewTimer((time.Duration)(t.readTimeoutSeconds) * time.Second)
select {
case conn.readCh <- resp.Data:
timer.Stop()
case <-timer.C:
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)
return
case <-tunnelCtx.Done():
klog.V(1).InfoS("Tunnel has been closed, the grpc connection to the proxy server will be closed", "connectionID", conn.connID)
}

case client.PacketType_CLOSE_RSP:
Expand Down

0 comments on commit a861c24

Please sign in to comment.