proc/native/linux: call waitFast instead of wait in addThread and halt (#855)

The condition that causes waitFast to fail can not happen in addThread
and halt so we don't need to call the slower wait.
This commit is contained in:
Alessandro Arzilli 2017-05-30 20:08:27 +02:00 committed by Derek Parker
parent 7f0c07902d
commit a4df01e105
2 changed files with 3 additions and 3 deletions

@ -120,7 +120,7 @@ func (dbp *Process) addThread(tid int, attach bool) (*Thread, error) {
// if we truly don't have permissions. // if we truly don't have permissions.
return nil, fmt.Errorf("could not attach to new thread %d %s", tid, err) return nil, fmt.Errorf("could not attach to new thread %d %s", tid, err)
} }
pid, status, err := dbp.wait(tid, 0) pid, status, err := dbp.waitFast(tid)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -131,7 +131,7 @@ func (dbp *Process) addThread(tid int, attach bool) (*Thread, error) {
dbp.execPtraceFunc(func() { err = syscall.PtraceSetOptions(tid, syscall.PTRACE_O_TRACECLONE) }) dbp.execPtraceFunc(func() { err = syscall.PtraceSetOptions(tid, syscall.PTRACE_O_TRACECLONE) })
if err == syscall.ESRCH { if err == syscall.ESRCH {
if _, _, err = dbp.wait(tid, 0); err != nil { if _, _, err = dbp.waitFast(tid); err != nil {
return nil, fmt.Errorf("error while waiting after adding thread: %d %s", tid, err) return nil, fmt.Errorf("error while waiting after adding thread: %d %s", tid, err)
} }
dbp.execPtraceFunc(func() { err = syscall.PtraceSetOptions(tid, syscall.PTRACE_O_TRACECLONE) }) dbp.execPtraceFunc(func() { err = syscall.PtraceSetOptions(tid, syscall.PTRACE_O_TRACECLONE) })

@ -22,7 +22,7 @@ func (t *Thread) halt() (err error) {
err = fmt.Errorf("halt err %s on thread %d", err, t.ID) err = fmt.Errorf("halt err %s on thread %d", err, t.ID)
return return
} }
_, _, err = t.dbp.wait(t.ID, 0) _, _, err = t.dbp.waitFast(t.ID)
if err != nil { if err != nil {
err = fmt.Errorf("wait err %s on thread %d", err, t.ID) err = fmt.Errorf("wait err %s on thread %d", err, t.ID)
return return