SMGenericV1.InitSession returning -1 for postpaid instead of nanoseconds, to keep OpenSIPS 2.3 happy

This commit is contained in:
DanB
2018-06-26 18:24:32 +02:00
parent 0a09ef8327
commit 00b64ccc63
2 changed files with 11 additions and 2 deletions

View File

@@ -1108,6 +1108,10 @@ func (smg *SMGeneric) BiRPCV1InitiateSession(clnt rpcclient.RpcClientConnection,
if err != rpcclient.ErrSessionNotFound {
err = utils.NewErrServerError(err)
}
return
}
if minMaxUsage == time.Duration(-1) {
*maxUsage = -1.0
} else {
*maxUsage = minMaxUsage.Seconds()
}
@@ -1122,6 +1126,7 @@ func (smg *SMGeneric) BiRPCV2InitiateSession(clnt rpcclient.RpcClientConnection,
if err != rpcclient.ErrSessionNotFound {
err = utils.NewErrServerError(err)
}
return
} else {
*maxUsage = minMaxUsage
}
@@ -1136,6 +1141,10 @@ func (smg *SMGeneric) BiRPCV1UpdateSession(clnt rpcclient.RpcClientConnection,
if err != rpcclient.ErrSessionNotFound {
err = utils.NewErrServerError(err)
}
return
}
if minMaxUsage == time.Duration(-1) {
*maxUsage = -1.0
} else {
*maxUsage = minMaxUsage.Seconds()
}

View File

@@ -150,7 +150,7 @@ func TestSMGBiRPCSessionAutomaticDisconnects(t *testing.T) {
smgEv, &maxUsage); err != nil {
t.Error(err)
}
if maxUsage != -1e-09 {
if maxUsage != -1 {
t.Error("Bad max usage: ", maxUsage)
}
// Make sure we are receiving a disconnect event
@@ -231,7 +231,7 @@ func TestSMGBiRPCSessionOriginatorTerminate(t *testing.T) {
smgEv, &maxUsage); err != nil {
t.Error(err)
}
if maxUsage != -1e-09 {
if maxUsage != -1 {
t.Error("Bad max usage: ", maxUsage)
}
time.Sleep(time.Duration(10 * time.Millisecond)) // Give time for debits to occur