Module: kamailio
Branch: master
Commit: 219ddbb54bb787a8f0673014c16e749eef40bdf4
URL:
https://github.com/kamailio/kamailio/commit/219ddbb54bb787a8f0673014c16e749…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-08-15T15:48:50+02:00
uac: use kam_rand() instead of rand()
- do kam_srand() when module is initialized
---
Modified: src/modules/uac/uac.c
Modified: src/modules/uac/uac_reg.c
---
Diff:
https://github.com/kamailio/kamailio/commit/219ddbb54bb787a8f0673014c16e749…
Patch:
https://github.com/kamailio/kamailio/commit/219ddbb54bb787a8f0673014c16e749…
---
diff --git a/src/modules/uac/uac.c b/src/modules/uac/uac.c
index d5ac59201d..844b6025ff 100644
--- a/src/modules/uac/uac.c
+++ b/src/modules/uac/uac.c
@@ -50,6 +50,7 @@
#include "../../core/kemi.h"
#include "../../core/rpc.h"
#include "../../core/rpc_lookup.h"
+#include "../../core/rand/kam_rand.h"
#include "../../core/cfg/cfg_struct.h"
#include "../dialog/dlg_load.h"
@@ -305,6 +306,7 @@ static int mod_init(void)
if(reg_db_url.s && reg_db_url.len>=0)
{
+ kam_srand(17 * getpid() + time(0));
if(!reg_contact_addr.s || reg_contact_addr.len<=0)
{
LM_ERR("contact address parameter not set\n");
@@ -343,6 +345,9 @@ static int mod_init(void)
static int child_init(int rank)
{
int pid;
+
+ kam_srand((11 + rank) * getpid() * 17 + time(0));
+
if (rank!=PROC_MAIN)
return 0;
@@ -361,6 +366,7 @@ static int child_init(int rank)
if (cfg_child_init())
return -1;
+ kam_srand(getpid() * 17 + time(0));
uac_reg_load_db();
uac_reg_timer(0);
for(;;){
diff --git a/src/modules/uac/uac_reg.c b/src/modules/uac/uac_reg.c
index cb7e4786af..d85d51c6a0 100644
--- a/src/modules/uac/uac_reg.c
+++ b/src/modules/uac/uac_reg.c
@@ -43,6 +43,7 @@
#include "../../core/parser/contact/parse_contact.h"
#include "../../core/rpc.h"
#include "../../core/rpc_lookup.h"
+#include "../../core/rand/kam_rand.h"
#include "../../modules/tm/tm_load.h"
@@ -538,7 +539,7 @@ int reg_ht_add(reg_uac_t *reg)
if (reg->reg_delay)
nr->reg_delay = reg->reg_delay;
else if (reg_random_delay>0)
- nr->reg_delay = rand() % reg_random_delay;
+ nr->reg_delay = kam_rand() % reg_random_delay;
nr->reg_init = time(NULL);
nr->h_uuid = reg_compute_hash(®->l_uuid);
nr->h_user = reg_compute_hash(®->l_username);