fix(inputs.opcua_listener): Avoid segfault if subscription was not successful (#13742)

This commit is contained in:
Sven Rebhan 2023-08-09 17:41:17 +02:00 committed by GitHub
parent 3fe151b28d
commit 96a9597720
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -83,10 +83,11 @@ func (o *SubscribeClient) Connect() error {
}
func (o *SubscribeClient) Stop(ctx context.Context) <-chan struct{} {
o.Log.Debugf("Opc Subscribe Stopped")
err := o.sub.Cancel(ctx)
if err != nil {
o.Log.Warn("Cancelling OPC UA subscription failed with error ", err)
o.Log.Debugf("Stopping OPC subscription...")
if o.sub != nil {
if err := o.sub.Cancel(ctx); err != nil {
o.Log.Warn("Cancelling OPC UA subscription failed with error ", err)
}
}
closing := o.OpcUAInputClient.Stop(ctx)
o.processingCancel()