Adding safeguards around Shutdown and AddTarget
This commit is contained in:
parent
8c9e75e5ab
commit
ddaa7bc4e7
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -9,4 +9,8 @@ massif.out
|
|||
|
||||
# binaries
|
||||
/chromedp-gen
|
||||
/chromedp-proxy
|
||||
/chromedp-cli
|
||||
/cmd/chromedp-gen/chromedp-gen
|
||||
/cmd/chromedp-gen/chromedp-proxy
|
||||
/cmd/chromedp-gen/chromedp-cli
|
||||
|
|
|
@ -75,6 +75,9 @@ func New(ctxt context.Context, opts ...Option) (*CDP, error) {
|
|||
|
||||
go func() {
|
||||
for t := range c.watch {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
go c.AddTarget(ctxt, t)
|
||||
}
|
||||
}()
|
||||
|
@ -153,9 +156,13 @@ func (c *CDP) Shutdown(ctxt context.Context, opts ...client.Option) error {
|
|||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
|
||||
if c.r != nil {
|
||||
return c.r.Shutdown(ctxt, opts...)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListTargets returns the target IDs of the managed targets.
|
||||
func (c *CDP) ListTargets() []string {
|
||||
c.RLock()
|
||||
|
|
Loading…
Reference in New Issue
Block a user