Skip to content

Commit

Permalink
client: use context
Browse files Browse the repository at this point in the history
  • Loading branch information
magiconair committed Jan 27, 2022
1 parent 50419c1 commit 3b9868f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func GetEndpoints(ctx context.Context, endpoint string, opts ...Option) ([]*ua.E
if err := c.Dial(ctx); err != nil {
return nil, err
}
defer c.Close()
defer c.CloseWithContext(ctx)
res, err := c.GetEndpointsWithContext(ctx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -195,14 +195,14 @@ func (c *Client) Connect(ctx context.Context) (err error) {

s, err := c.CreateSessionWithContext(ctx, c.cfg.session)
if err != nil {
c.Close()
c.CloseWithContext(ctx)
stats.RecordError(err)

return err
}

if err := c.ActivateSessionWithContext(ctx, s); err != nil {
c.Close()
c.CloseWithContext(ctx)
stats.RecordError(err)

return err
Expand All @@ -221,7 +221,7 @@ func (c *Client) Connect(ctx context.Context) (err error) {
// todo(fs): see the discussion in https://github.com/gopcua/opcua/pull/512
// todo(fs): and you should find a commit that implements this option.
if err := c.UpdateNamespacesWithContext(ctx); err != nil {
c.Close()
c.CloseWithContext(ctx)
stats.RecordError(err)

return err
Expand Down

0 comments on commit 3b9868f

Please sign in to comment.