Description

ims_registrar_pcscf module create a process with rank 1 (PROC_SIPINIT) if reginfo flag is open..

This is wrong because it is written that PROC_SIPINIT rank should be given only to the first worker process.

#define PROC_SIPINIT      1  /**< First (special) SIP worker - some modules do
						special processing in this child, like loading db data */

This leads to a problem. ims_usrloc_pcscf loads registration records from the db twice.

The codes are demonstrated below.

Similar old issue exists here for another module:
#975

Troubleshooting

Reproduction

Debugging Data

(paste your debugging data here)

Log Messages

Here are fork operations and their ranks:

[root@n5gc-ims-dev src]# cat /usr/src/erhan5.log | grep init_mod_child | grep ims_usrloc_pcscf
 0(10662) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 0 rank -127: ims_usrloc_pcscf [main]
 1(10671) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 1 rank 1: ims_usrloc_pcscf [udp receiver child=0 sock=10.10.12.101:5060 (172.30.65.101:5060)]
 3(10673) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 3 rank 3: ims_usrloc_pcscf [udp receiver child=2 sock=10.10.12.101:5060 (172.30.65.101:5060)]
 2(10672) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 2 rank 2: ims_usrloc_pcscf [udp receiver child=1 sock=10.10.12.101:5060 (172.30.65.101:5060)]
 5(10675) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 5 rank -1: ims_usrloc_pcscf [slow timer]
 0(10662) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 0 rank 0: ims_usrloc_pcscf [main]
 6(10679) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 6 rank -1: ims_usrloc_pcscf [timer]
 4(10674) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 4 rank 4: ims_usrloc_pcscf [udp receiver child=3 sock=10.10.12.101:5060 (172.30.65.101:5060)]
 7(10680) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 7 rank -1: ims_usrloc_pcscf [secondary timer]
 8(10686) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 8 rank 1: ims_usrloc_pcscf [RegInfo Event Processor]
 9(10687) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 9 rank -1: ims_usrloc_pcscf [Dialog Clean Timer]
10(10688) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 10 rank -2: ims_usrloc_pcscf [ctl handler]
11(10689) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 11 rank 5: ims_usrloc_pcscf [tcp receiver (generic) child=0]
12(10694) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 12 rank 6: ims_usrloc_pcscf [tcp receiver (generic) child=1]
13(10695) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 13 rank 7: ims_usrloc_pcscf [tcp receiver (generic) child=2]
14(10697) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 14 rank 8: ims_usrloc_pcscf [tcp receiver (generic) child=3]
15(10699) DEBUG: <core> [core/sr_module.c:845]: init_mod_child(): idx 15 rank -4: ims_usrloc_pcscf [tcp main process]

SIP Traffic

(paste your sip traffic here)

Possible Solutions

In following code ims_registrar_pcscf module create a process with rank 1 (PROC_SIPINIT) :
fork_process(PROC_SIPINIT, "RegInfo Event Processor", 1);


static int child_init(int rank)
{

	LM_DBG("Initialization of module in child [%d] \n", rank);
    if ((subscribe_to_reginfo == 1) && (rank == PROC_MAIN)) {
	     LM_DBG("Creating RegInfo Event Processor process\n");
	    int pid = fork_process(PROC_SIPINIT, "RegInfo Event Processor", 1);
	    if (pid < 0)
		return -1; //error
	    if (pid == 0) {
		if (cfg_child_init())
		    return -1; //error
		reginfo_event_process();
	    }
	}
    
	if (rank == PROC_MAIN || rank == PROC_TCP_MAIN)
		return 0;
	if (rank == 1) {
		/* init stats */
		//TODO if parameters are modified via cfg framework do i change them?
		//update_stat( max_expires_stat, default_registrar_cfg.max_expires ); update_stat( max_contacts_stat, default_registrar_cfg.max_contacts ); update_stat( default_expire_stat, default_registrar_cfg.default_expires );
	}

	/* don't do anything for main process and TCP manager process */
	if (rank == PROC_MAIN || rank == PROC_TCP_MAIN)
		return 0;

	return 0;
}

Here is how ims_usrloc_pcscf loads records from db at its child init callback function:

	if (_rank==PROC_SIPINIT && db_mode!=DB_ONLY) {
		// if cache is used, populate domains from DB
		for( ptr=root ; ptr ; ptr=ptr->next) {
			LM_DBG("Preloading domain %.*s\n", ptr->name.len, ptr->name.s);
			if (preload_udomain(ul_dbh, ptr->d) < 0) {
				LM_ERR("child(%d): failed to preload domain '%.*s'\n",
						_rank, ptr->name.len, ZSW(ptr->name.s));
				return -1;
			}
		}
	}

Additional Information

 it exists at latest version on master branch.
[here](https://github.com/kamailio/kamailio/blob/master/src/modules/ims_registrar_pcscf/ims_registrar_pcscf_mod.c#L328)
CentOS 7.1


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.