### Description
usrloc should not leave any ucontact behind when on DB_ONLY
### Troubleshooting
#### Reproduction
```
event_route[usrloc:contact-expired] {
$var(uri) = "sip:" + $ulc(exp=>aor) + "@localhost";
xinfo("expired contact for $ulc(exp=>aor) uri:$var(uri)");
reg_fetch_contacts("location", "$var(uri)", "caller");
if($(ulc(caller=>count)) < 0) {
xinfo("no more contacts for $ulc(exp=>aor)\n");
} else {
xinfo("$ulc(exp=>aor) has $(ulc(caller=>count)) contacts
left\n");
}
return;
}
```
REGISTER a subscriber and let it expire
#### Debugging Data
after
```
root@16d059a62a76:/code/utils/kamcmd# sh /kamdev/shm_dump.sh 1
2 qm_status: alloc'd from usrloc: dlist.c: new_dlist(557)
2 qm_status: alloc'd from usrloc: dlist.c: new_dlist(565)
2 qm_status: alloc'd from usrloc: ucontact.c: new_ucontact(96)
2 qm_status: alloc'd from usrloc: udomain.c: new_udomain(91)
2 qm_status: alloc'd from usrloc: udomain.c: new_udomain(98)
2 qm_status: alloc'd from usrloc: ul_callback.c: init_ulcb_list(45)
2 qm_status: alloc'd from usrloc: ul_callback.c: register_ulcb(94)
6 qm_status: alloc'd from usrloc: udomain.c: build_stat_name(56)
10 qm_status: alloc'd from usrloc: ../../core/ut.h: shm_str_dup(722)
```
#### Log Messages
```
1(4112) DEBUG: usrloc [udomain.c:996]: udomain_contact_expired_cb(): calling contact
expired records - cycle [1]
1(4112) DEBUG: usrloc [ul_callback.h:83]: run_ul_callbacks(): contact=0x7f621e476bd0,
callback type 8/8, id 0 entered
1(4112) exec: *** cfgtrace:request_route=[usrloc:contact-expired]
c=[/kamdev/kamailio.cfg] l=1015 a=63 n=assign
1(4112) exec: *** cfgtrace:request_route=[usrloc:contact-expired]
c=[/kamdev/kamailio.cfg] l=1016 a=25 n=xinfo
1(4112) INFO: <script>: expired contact for 1001-whatever
uri:sip:1001-whatever@localhost 1(4112) exec: ***
cfgtrace:request_route=[usrloc:contact-expired] c=[/kamdev/kamailio.cfg] l=1017 a=27
n=reg_fetch_contacts
1(4112) exec: *** cfgtrace:request_route=[usrloc:contact-expired]
c=[/kamdev/kamailio.cfg] l=1022 a=16 n=if
1(4112) exec: *** cfgtrace:request_route=[usrloc:contact-expired]
c=[/kamdev/kamailio.cfg] l=1021 a=25 n=xinfo
1(4112) INFO: <script>: 1001-whatever has 1 contacts left
1(4112) exec: *** cfgtrace:request_route=[usrloc:contact-expired]
c=[/kamdev/kamailio.cfg] l=1023 a=2 n=return
```
### Possible Solutions
I think the problem resides on udomain_contact_expired_cb() and using get_urecord(). PR
will follow.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 5.4.0-dev0 (x86_64/linux) 075c74
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST,
DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY,
USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR,
USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535,
DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 075c74
compiled on 10:36:45 Oct 3 2019 with gcc 8.3.0
```
--
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/2089