### Description I'm testing the presence feature, on branch 5.2 last version 1e56e4d . modparam("presence_xml", "db_url", DBURL) Can not set db_url of the presence_xml correct value. presence_xml db_url always the default value(DEFAULT_DB_URL). The same way, presence db_url is right.
#### Debugging Data presence.cfg file: ``` debug=3 #!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio52"
/* set paths to location of modules */ mpath="/usr/local/kamailio/lib64/kamailio/modules/"
loadmodule "db_mysql.so" loadmodule "tm.so" loadmodule "sl.so"
loadmodule "presence.so" loadmodule "presence_xml.so"
modparam("presence", "db_url", DBURL)
modparam("presence_xml", "db_url", DBURL) modparam("presence_xml", "integrated_xcap_server", 1)
request_route { exit; } ```
#### Log Messages
``` 0(76822) DEBUG: <core> [core/sr_module.c:896]: init_mod(): presence 0(76822) DEBUG: presence [presence.c:282]: mod_init(): db_url=mysql://kamailio:kamailiorw@localhost/kamailio52/48/0x102b9e860 .... 0(76822) DEBUG: <core> [core/sr_module.c:896]: init_mod(): presence_xml 0(76822) DEBUG: presence_xml [presence_xml.c:159]: mod_init(): db_url=mysql://kamailio:kamailiorw@localhost/kamailio/46/0x103cf2d64 ... 0(76822) DEBUG: presence_xml [add_events.c:139]: xml_add_events(): added 'xcap-diff' event to presence module 0(76822) DEBUG: <core> [core/sr_module.c:619]: find_mod_export_record(): found export of <db_bind_api> in module db_mysql [/usr/local/kamailio/lib64/kamailio/modules/db_mysql.so] 0(76822) DEBUG: <core> [db.c:210]: db_bind_mod(): using db bind api for db_mysql 0(76822) DEBUG: <core> [db.c:315]: db_do_init2(): connection 0x102bac2e8 not found in pool 0(76822) DEBUG: db_mysql [km_my_con.c:108]: db_mysql_new_connection(): opening connection: mysql://xxxx:xxxx@localhost/kamailio 0(76822) ERROR: db_mysql [km_my_con.c:139]: db_mysql_new_connection(): driver error: Unknown database 'kamailio' 0(76822) ERROR: <core> [db.c:319]: db_do_init2(): could not add connection to the pool 0(76822) ERROR: presence_xml [presence_xml.c:214]: mod_init(): while connecting to database 0(76822) ERROR: <core> [core/sr_module.c:899]: init_mod(): Error while initializing module presence_xml (/usr/local/kamailio/lib64/kamailio/modules/presence_xml.so) ERROR: error while initializing modules
```
The correct db_url is #!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio52" I don't know why presence_xml db_url always the default value in the source code DEFAULT_DB_URL.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` version: kamailio 5.2.0 (x86_64/darwin) 1e56e4 flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, select, kqueue. id: 1e56e4 compiled on 23:15:49 Jan 12 2019 with gcc Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1 Apple LLVM version 10.0.0 (clang-1000.11.45.5) Target: x86_64-apple-darwin18.2.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin ```
* **Operating System**:
``` MacOS ```
I found a confusing thing. I simplified the configuration file ``` debug=3
/* set paths to location of modules */ mpath="/usr/local/kamailio/lib64/kamailio/modules/"
loadmodule "db_mysql.so" loadmodule "tm.so" loadmodule "sl.so"
loadmodule "presence.so" loadmodule "presence_xml.so"
modparam("presence_xml", "db_url", "mysql://kamailio:kamailiorw@localhost/kamailio52")
request_route { exit; } ``` #### Log Messages About db_url ``` 0(4147) DEBUG: <core> [core/modparam.c:83]: set_mod_param_regex(): 'presence_xml' matches module 'presence_xml' 0(4147) DEBUG: <core> [core/sr_module.c:711]: find_param_export(): found <db_url> in module presence_xml [/usr/local/kamailio/lib64/kamailio/modules/presence_xml.so] 0(4147) DEBUG: <core> [core/modparam.c:99]: set_mod_param_regex(): found <db_url> in module presence_xml [/usr/local/kamailio/lib64/kamailio/modules/presence_xml.so] ... 0(4149) DEBUG: <core> [core/sr_module.c:896]: init_mod(): presence 0(4149) DEBUG: presence [presence.c:282]: mod_init(): db_url=mysql://kamailio:kamailiorw@localhost/kamailio52/48/0x106853338 ... 0(4149) DEBUG: <core> [core/sr_module.c:896]: init_mod(): presence_xml 0(4149) DEBUG: presence_xml [presence_xml.c:159]: mod_init(): db_url=mysql://kamailio:kamailiorw@localhost/kamailio/46/0x1079a7d64 ... 0(4149) DEBUG: db_mysql [km_my_con.c:108]: db_mysql_new_connection(): opening connection: mysql://xxxx:xxxx@localhost/kamailio 0(4149) ERROR: db_mysql [km_my_con.c:139]: db_mysql_new_connection(): driver error: Unknown database 'kamailio' 0(4149) ERROR: <core> [db.c:319]: db_do_init2(): could not add connection to the pool 0(4149) ERROR: presence_xml [presence_xml.c:214]: mod_init(): while connecting to database 0(4149) ERROR: <core> [core/sr_module.c:899]: init_mod(): Error while initializing module presence_xml (/usr/local/kamailio/lib64/kamailio/modules/presence_xml.so) ERROR: error while initializing modules ``` I set presence_xml db_url only. But why presence db_url be set? And presence_xml db_url still is the default value.
It was a "silent" conflict in declaration of db_url variable between the presence and presence_xml modules -- the presence_xml is built on top of presence module, and it was including the `../presence/presence.h` header file, which already declared db_url as extern.
I pushed couple of patches to master branch, can you try it? If all ok, I will backport to branch 5.2 (5.2.1 being planned to be released in a few days). Thanks!
Closed #1809.
In preparation to release v5.2.1, I already backported the related patches. I am closing this one, if there are still issues, reopen.