github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/fuzzer/queue/retry.go (about) 1 // Copyright 2024 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package queue 5 6 type retryer struct { 7 pq *PlainQueue 8 base Source 9 } 10 11 // Retry adds a layer that resends results with Status=Restarted. 12 func Retry(base Source) Source { 13 return &retryer{ 14 base: base, 15 pq: Plain(), 16 } 17 } 18 19 func (r *retryer) Next() *Request { 20 req := r.pq.tryNext() 21 if req == nil { 22 req = r.base.Next() 23 } 24 if req != nil { 25 req.OnDone(r.done) 26 } 27 return req 28 } 29 30 func (r *retryer) done(req *Request, res *Result) bool { 31 // The input was on a restarted VM. 32 if res.Status == Restarted { 33 r.pq.Submit(req) 34 return false 35 } 36 // Retry important requests from crashed VMs once. 37 if res.Status == Crashed && req.Important && !req.onceCrashed { 38 req.onceCrashed = true 39 r.pq.Submit(req) 40 return false 41 } 42 return true 43 }