[VOL-4469] Onu adapter reconcilement may stuck on VLAN processing, especially in TT traffic scenarios
Signed-off-by: mpagenko <michael.pagenkopf@adtran.com>
Change-Id: If321388c67e2e52eb04b8a55167eb3c1c7575e5d
diff --git a/internal/pkg/common/utils.go b/internal/pkg/common/utils.go
index e8a161c..3eb4121 100755
--- a/internal/pkg/common/utils.go
+++ b/internal/pkg/common/utils.go
@@ -27,6 +27,7 @@
"regexp"
"strconv"
"strings"
+ "time"
"github.com/looplab/fsm"
me "github.com/opencord/omci-lib-go/v2/generated"
@@ -161,3 +162,22 @@
}
return (VoipUniBaseEID + uniPortMacBpNo), nil
}
+
+//WaitTimeout of waitGroupWithTimeOut is blocking
+// returns true, if the wg request was executed successfully, false on timeout
+func (wg *WaitGroupWithTimeOut) WaitTimeout(timeout time.Duration) bool {
+ done := make(chan struct{})
+
+ go func() {
+ defer close(done)
+ wg.Wait()
+ }()
+
+ select {
+ case <-done:
+ return true
+
+ case <-time.After(timeout):
+ return false
+ }
+}