-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/fuzzer: introduce a request restarter layer
Make Result statuses more elaborate. Instead of retrying inputs directly in rpc.go, extract this logic to a separate entity in pkg/fuzzer/queue.
- Loading branch information
Showing
6 changed files
with
89 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 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 | ||
} | ||
|
||
// NewRetryer adds a layer that resends results with Status=Restarted. | ||
func NewRetryer(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 | ||
} | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters