<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please
use this template only for bug reports.
If you have questions about using Kamailio or related to its configuration file, ask on
sr-users mailing list:
*
http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
If you have questions about developing extensions to Kamailio or its existing C code, ask
on sr-dev mailing list:
*
http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Please try to fill this template as much as possible for any issue. It helps the
developers to troubleshoot the issue.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment).
-->
### 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:
https://github.com/kamailio/kamailio/issues/975
### Troubleshooting
#### Reproduction
<!--
If the issue can be reproduced, describe how it can be done.
-->
#### Debugging Data
<!--
If you got a core dump, use gdb to extract troubleshooting data - full backtrace,
local variables and the list of the code at the issue location.
gdb /path/to/kamailio /path/to/corefile
bt full
info locals
list
If you are familiar with gdb, feel free to attach more of what you consider to
be relevant.
-->
```
(paste your debugging data here)
```
#### Log Messages
<!--
Check the syslog file and if there are relevant log messages printed by Kamailio, add them
next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
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
<!--
If the issue is exposed by processing specific SIP messages, grab them with ngrep or save
in a pcap file, then add them next, or attach to issue, or provide a link to download them
(e.g., to a pastebin site).
-->
```
(paste your sip traffic here)
```
### Possible Solutions
<!--
If you found a solution or workaround for the issue, describe it. Ideally, provide a pull
request with a fix.
-->
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
* **Kamailio Version** - output of `kamailio -v`
```
it exists at latest version on master branch.
[
here](https://github.com/kamailio/kamailio/blob/master/src/modules/ims_regi…
```
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04,
CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `uname -a`)
-->
```
CentOS 7.1
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2809