SMGeneric using cloning for replication to avoid concurrency

This commit is contained in:
DanB
2016-12-15 12:54:41 +01:00
parent 488346c1ed
commit 49924fc210
3 changed files with 17 additions and 1 deletions

View File

@@ -597,3 +597,7 @@ func testOnStorITCacheAlias(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v", als, rcv)
}
}
func testOnStorITCacheResourceLimit(t *testing.T) {
}

View File

@@ -450,7 +450,10 @@ func (smg *SMGeneric) replicateSessions(cgrID string) (err error) {
return
}
smg.aSessionsMux.RLock()
aSessions := smg.activeSessions[cgrID]
var aSessions []*SMGSession
if err = utils.Clone(smg.activeSessions[cgrID], &aSessions); err != nil {
return
}
smg.aSessionsMux.RUnlock()
var wg sync.WaitGroup
for _, rplConn := range smg.smgReplConns {

View File

@@ -630,6 +630,15 @@ func TestClone(t *testing.T) {
if b != a {
t.Error("Expected:", a, ", received:", b)
}
// Clone from an interface
c := "mystr"
ifaceC := interface{}(c)
clndIface := reflect.Indirect(reflect.New(reflect.TypeOf(ifaceC))).Interface().(string)
if err := Clone(ifaceC, &clndIface); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(ifaceC, clndIface) {
t.Errorf("Expecting: %+v, received: %+v", ifaceC, clndIface)
}
}
func TestIntPointer(t *testing.T) {