Skip to content

Commit

Permalink
Reset read timeout to disabled in GetNameVersion
Browse files Browse the repository at this point in the history
Fix a bug where the read timeout is not disabled if an error is
returned from ReadFrame (such as a timeout).

Thanks to Danny van Heumen <danny@dannyvanheumen.nl> for pointing this
out.
  • Loading branch information
dehanj authored and mchack-work committed Oct 24, 2024
1 parent e16b32b commit 8d03178
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions tkeyclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,14 @@ func (tk TillitisKey) GetNameVersion() (*NameVersion, error) {
return nil, err
}

if err = tk.SetReadTimeout(2); err != nil {
return nil, err
}
tk.SetReadTimeoutNoErr(2)
defer tk.SetReadTimeoutNoErr(0)

rx, _, err := tk.ReadFrame(rspGetNameVersion, id)
if err != nil {
return nil, fmt.Errorf("ReadFrame: %w", err)
}

if err = tk.SetReadTimeout(0); err != nil {
return nil, fmt.Errorf("SetReadTimeout: %w", err)
}

nameVer := &NameVersion{}
nameVer.Unpack(rx[2:])

Expand Down

0 comments on commit 8d03178

Please sign in to comment.