Skip to content

Commit

Permalink
pkg/ipc: add rate limiting for akaros
Browse files Browse the repository at this point in the history
  • Loading branch information
dvyukov committed Jul 5, 2018
1 parent 1c9d305 commit 63226a5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/ipc/ipc.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ type Config struct {

// BufferSize is the size of the internal buffer for executor output.
BufferSize uint64

// RateLimit flag tells to start one executor at a time.
// Currently used only for akaros where executor is actually ssh.
RateLimit bool
}

func DefaultConfig(target *prog.Target) (*Config, *ExecOpts, error) {
Expand All @@ -107,6 +111,7 @@ func DefaultConfig(target *prog.Target) (*Config, *ExecOpts, error) {
Timeout: *flagTimeout,
AbortSignal: *flagAbortSignal,
BufferSize: *flagBufferSize,
RateLimit: target.OS == "akaros",
}
if *flagSignal {
c.Flags |= FlagSignal
Expand Down Expand Up @@ -532,8 +537,13 @@ type callReply struct {
// signal/cover/comps follow
}

var rateLimit = time.NewTicker(3 * time.Second)

func makeCommand(pid int, bin []string, config *Config, inFile *os.File, outFile *os.File,
outmem []byte) (*command, error) {
if config.RateLimit {
<-rateLimit.C
}
dir, err := ioutil.TempDir("./", "syzkaller-testdir")
if err != nil {
return nil, fmt.Errorf("failed to create temp dir: %v", err)
Expand Down

0 comments on commit 63226a5

Please sign in to comment.