Commit 2029edb8 authored by inphi's avatar inphi

remove dup waitErr chan read

parent 877fcf88
......@@ -188,15 +188,6 @@ func (p *ProcessPreimageOracle) Close() error {
if p.cmd == nil {
return nil
}
// We first check if the process has already exited before signaling.
// Note: This is a teeny bit racy since the process could exit after the check
// above and another process is assigned the same pid.
select {
case err := <-p.waitErr:
return err
case <-time.After(time.Second * 1):
// give the wait goroutine time to reap process
}
_ = p.cmd.Process.Signal(os.Interrupt)
return <-p.waitErr
}
......
......@@ -8,7 +8,7 @@ import (
)
// FilePoller is a ReadWriteCloser that polls the underlying file channel for reads and writes
// until its context is done. This is useful in detecting when the other end of a
// until its context is done. This is useful to detect when the other end of a
// blocking pre-image channel is no longer available.
type FilePoller struct {
File FileChannel
......@@ -27,7 +27,7 @@ func (f *FilePoller) Read(b []byte) (int, error) {
var read int
for {
if err := f.File.Reader().SetReadDeadline(time.Now().Add(f.pollTimeout)); err != nil {
panic(err)
return 0, err
}
n, err := f.File.Read(b[read:])
if errors.Is(err, os.ErrDeadlineExceeded) {
......@@ -47,7 +47,7 @@ func (f *FilePoller) Write(b []byte) (int, error) {
var written int
for {
if err := f.File.Writer().SetWriteDeadline(time.Now().Add(f.pollTimeout)); err != nil {
panic(err)
return 0, err
}
n, err := f.File.Write(b[written:])
if errors.Is(err, os.ErrDeadlineExceeded) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment