You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2022/08/15 12:47:18 UTC

[plc4x] branch develop updated: fix(plc4go): fixed close result of empty connection cache

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 9f941a4e5 fix(plc4go): fixed close result of empty connection cache
9f941a4e5 is described below

commit 9f941a4e55db66193ff91c34a56cdeaea802d3e8
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon Aug 15 14:47:11 2022 +0200

    fix(plc4go): fixed close result of empty connection cache
---
 plc4go/pkg/api/cache/plc_connection_cache.go | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/plc4go/pkg/api/cache/plc_connection_cache.go b/plc4go/pkg/api/cache/plc_connection_cache.go
index aa95c9ecd..a5bb8edbd 100644
--- a/plc4go/pkg/api/cache/plc_connection_cache.go
+++ b/plc4go/pkg/api/cache/plc_connection_cache.go
@@ -160,6 +160,15 @@ func (t *plcConnectionCache) Close() <-chan PlcConnectionCacheCloseResult {
 		t.cacheLock.Lock()
 		defer t.cacheLock.Unlock()
 
+		if len(t.connections) == 0 {
+			select {
+			case ch <- newDefaultPlcConnectionCacheCloseResult(t, nil):
+			case <-time.After(time.Millisecond * 10):
+			}
+			log.Debug().Msg("Closing connection cache finished.")
+			return
+		}
+
 		for _, cc := range t.connections {
 			// Mark the connection as being closed to not try to re-establish it.
 			cc.closed = true