all: Recover from panics in goroutines

This commit is contained in:
Matthew Holt 2020-05-12 11:36:20 -06:00
parent 44536a7594
commit aef560c7fc
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
10 changed files with 86 additions and 33 deletions

View file

@ -16,6 +16,7 @@ package standardstek
import (
"log"
"runtime/debug"
"sync"
"time"
@ -81,6 +82,11 @@ func (s *standardSTEKProvider) Next(doneChan <-chan struct{}) <-chan [][32]byte
// rotate rotates keys on a regular basis, sending each updated set of
// keys down keysChan, until doneChan is closed.
func (s *standardSTEKProvider) rotate(doneChan <-chan struct{}, keysChan chan<- [][32]byte) {
defer func() {
if err := recover(); err != nil {
log.Printf("[PANIC] standard STEK rotation: %v\n%s", err, debug.Stack())
}
}()
for {
select {
case now := <-s.timer.C: