Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
middleware/hsm: use blocking call over timeout (for now) (#289)
Browse files Browse the repository at this point in the history
The serial package's max timeout is silently capped at 25.5s:

https://github.com/tarm/serial/blob/98f6abe2eb07edd42f6dfa2a934aea469acc29b7/serial.go#L158

We need longer for the blocking HSM operations to be able to finish.

We might add a shorter timeout and a repeater in the future, to still
abort after a (long) time, but unless we fully go async, all those
solutions are suboptimal.
  • Loading branch information
benma authored and Stadicus committed Nov 28, 2019
1 parent a37de81 commit 20bf479
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions middleware/src/hsm/hsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ func NewHSM(serialPort string) *HSM {

// openSerial opens the serial port. This operation is cheap (file descriptor open/close), so it can
// be done before every use. readTimeout is the timeout when waiting for a response of the HSM (this
// function does not block on this!). If nil, defaults to 20 minutes, which is large enough so
// blocking operations like verifying the pairing will hopefully not timeout.
// function does not block on this!). If nil, defaults to blocking (no timeout).
func (hsm *HSM) openSerial(readTimeout *time.Duration) (*serial.Port, error) {
readTimeoutOrDefault := 20 * time.Minute
readTimeoutOrDefault := 0 * time.Second // blocking
if readTimeout != nil {
readTimeoutOrDefault = *readTimeout
}
Expand Down

0 comments on commit 20bf479

Please sign in to comment.