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