Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix cpu exp destroy mode when suid is empty #118

Merged
merged 1 commit into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ var cl = channel.NewLocalChannel()
// stop hang process
func Destroy(ctx context.Context, c spec.Channel, action string) *spec.Response {
suid := ctx.Value(spec.Uid)
/* If suid is specified, it will be deleted exactly
/* If suid is specified, it will be deleted exactly
* according to suid, otherwise it will be based on action. */
if suid != nil && suid != spec.UnknownUid {
if suid != nil && suid != spec.UnknownUid && suid != "" {
ctx = context.WithValue(ctx, channel.ProcessKey, suid)
} else {
ctx = context.WithValue(ctx, channel.ProcessKey, action)
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ func main() {
}

uid := expModel.ActionFlags[model.UidFlag.Name]
if uid == "" {
uid, _ = util.GenerateUid()
}

ctx = context.WithValue(ctx, spec.Uid, uid)
if mode == spec.Destroy {
ctx = spec.SetDestroyFlag(ctx, uid)
} else {
if uid == "" {
uid, _ = util.GenerateUid()
}
}

if expModel.ActionFlags[model.DebugFlag.Name] == spec.True {
Expand Down