pro-bing icon indicating copy to clipboard operation
pro-bing copied to clipboard

func `RunWithContext` didn't exit as expected

Open ruokeqx opened this issue 2 years ago • 1 comments

// RunWithContext runs the pinger with a context. This is a blocking function that will exit when it's
// done or if the context is canceled. If Count or Interval are not specified, it will run continuously until
// it is interrupted.
func (p *Pinger) RunWithContext(ctx context.Context) error {
...
	if p.ipaddr == nil {
		err = p.Resolve()
	}
...
	return p.run(ctx, conn)
}

function RunWithContext didn't exit as expected as it will block in p.Resolve(), it didn't exit even when ctx is canceled before it was passed in

ruokeqx avatar Sep 05 '23 12:09 ruokeqx

A workaround is to use p.ResolveTimeout for the moment, yet IMHO this should be fixed to use resolve using the passed context.

thediveo avatar Apr 22 '24 13:04 thediveo