diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-11-25 09:17:50 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-12-28 14:22:41 +0100 |
| commit | cbd0445ec3b0b184db66966d8a47e6b37d13692e (patch) | |
| tree | 14ed47723c325ef1b388e4e732a70c0fed4fa101 /pkg/ipc/ipc.go | |
| parent | 2242f77fdc5a6c50bd8fa1021d2abc8b83e09e8d (diff) | |
all: make timeouts configurable
Add sys/targets.Timeouts struct that parametrizes timeouts throughout the system.
The struct allows to control syscall/program/no output timeouts for OS/arch/VM/etc.
See comment on the struct for more details.
Diffstat (limited to 'pkg/ipc/ipc.go')
| -rw-r--r-- | pkg/ipc/ipc.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go index 0f1bd50a6..7e0bf7e94 100644 --- a/pkg/ipc/ipc.go +++ b/pkg/ipc/ipc.go @@ -73,6 +73,8 @@ type Config struct { // Flags are configuation flags, defined above. Flags EnvFlags + + Timeouts targets.Timeouts } type CallFlags uint32 @@ -154,6 +156,10 @@ func FlagsToSandbox(flags EnvFlags) string { } func MakeEnv(config *Config, pid int) (*Env, error) { + if config.Timeouts.Slowdown == 0 || config.Timeouts.Scale == 0 || + config.Timeouts.Syscall == 0 || config.Timeouts.Program == 0 { + return nil, fmt.Errorf("ipc.MakeEnv: uninitialized timeouts (%+v)", config.Timeouts) + } var inf, outf *os.File var inmem, outmem []byte if config.UseShmem { @@ -731,9 +737,9 @@ func (c *command) exec(opts *ExecOpts, progData []byte) (output []byte, hanged b pid: uint64(c.pid), faultCall: uint64(opts.FaultCall), faultNth: uint64(opts.FaultNth), - syscallTimeoutMS: 50, - programTimeoutMS: 5000, - slowdownScale: 1, + syscallTimeoutMS: uint64(c.config.Timeouts.Syscall / time.Millisecond), + programTimeoutMS: uint64(c.config.Timeouts.Program / time.Millisecond), + slowdownScale: uint64(c.config.Timeouts.Scale), progSize: uint64(len(progData)), } reqData := (*[unsafe.Sizeof(*req)]byte)(unsafe.Pointer(req))[:] |
