diff --git a/modules/mid_registrar/ulcb.c b/modules/mid_registrar/ulcb.c index f6d8a5a221c..0ec5e3f6fa0 100644 --- a/modules/mid_registrar/ulcb.c +++ b/modules/mid_registrar/ulcb.c @@ -229,15 +229,14 @@ void mid_reg_ct_event(void *binding, ul_cb_type type) LM_DBG("Contact callback (%d): contact='%.*s'\n", type, c->c.len, c->c.s); - if (type & (UL_CONTACT_DELETE|UL_CONTACT_EXPIRE)) { - if (reg_mode == MID_REG_THROTTLE_CT) { - skip_dereg = ul.get_ucontact_key(c, &ul_key_skip_dereg); - if (skip_dereg && skip_dereg->i == 1) - return; - - if (unregister_contact(c) != 0) - LM_ERR("failed to unregister contact\n"); - } + if (type & (UL_CONTACT_DELETE|UL_CONTACT_EXPIRE) + && reg_mode == MID_REG_THROTTLE_CT) { + skip_dereg = ul.get_ucontact_key(c, &ul_key_skip_dereg); + if ((skip_dereg && skip_dereg->i == 1) || !ul.is_my_ucontact(c)) + return; + + if (unregister_contact(c) != 0) + LM_ERR("failed to unregister contact\n"); } } diff --git a/modules/usrloc/dlist.c b/modules/usrloc/dlist.c index 570980c44ad..728091f91b3 100644 --- a/modules/usrloc/dlist.c +++ b/modules/usrloc/dlist.c @@ -716,7 +716,7 @@ get_domain_mem_ucontacts(udomain_t *d,void *buf, int *len, unsigned int flags, /* a lot slower than fetching all tags before the outermost * loop, but at least we have proper responsiveness to tag * switches! */ - if (pinging_mode == PMD_OWNERSHIP && !is_my_contact(c)) + if (pinging_mode == PMD_OWNERSHIP && !_is_my_ucontact(c)) continue; needed = (int)((c->received.s? diff --git a/modules/usrloc/ucontact.c b/modules/usrloc/ucontact.c index 88e534462a4..46ca2498830 100644 --- a/modules/usrloc/ucontact.c +++ b/modules/usrloc/ucontact.c @@ -1045,3 +1045,8 @@ int_str_t *put_ucontact_key(ucontact_t* _ct, const str* _key, { return kv_put(_ct->kv_storage, _key, _val); } + +int is_my_ucontact(ucontact_t *c) +{ + return _is_my_ucontact(c); +} diff --git a/modules/usrloc/ucontact.h b/modules/usrloc/ucontact.h index 352b2c84574..c39e0d56656 100644 --- a/modules/usrloc/ucontact.h +++ b/modules/usrloc/ucontact.h @@ -199,6 +199,7 @@ typedef struct { int ucontact_coords_cmp(ucontact_coords a, ucontact_coords b); void free_ucontact_coords(ucontact_coords coords); +int is_my_ucontact(ucontact_t *c); /*! \brief * ancient time used for marking the contacts forced to expired diff --git a/modules/usrloc/ul_cluster.h b/modules/usrloc/ul_cluster.h index 97e183d69fc..93df5c2ad80 100644 --- a/modules/usrloc/ul_cluster.h +++ b/modules/usrloc/ul_cluster.h @@ -50,7 +50,7 @@ extern str ul_shtag_key; extern str contact_repl_cap; int ul_init_cluster(void); -#define is_my_contact(__ct) \ +#define _is_my_ucontact(__ct) \ (!__ct->shtag.s || \ clusterer_api.shtag_get(&__ct->shtag, location_cluster) \ == SHTAG_STATE_ACTIVE) diff --git a/modules/usrloc/usrloc.c b/modules/usrloc/usrloc.c index 584228d1cab..75da0021e39 100644 --- a/modules/usrloc/usrloc.c +++ b/modules/usrloc/usrloc.c @@ -78,6 +78,7 @@ int bind_usrloc(usrloc_api_t* api) api->delete_ucontact_from_coords = delete_ucontact_from_coords; api->ucontact_coords_cmp = ucontact_coords_cmp; api->free_ucontact_coords = free_ucontact_coords; + api->is_my_ucontact = is_my_ucontact; api->next_contact_id = next_contact_id; api->update_sipping_latency = update_sipping_latency; api->raise_ev_ct_refresh = ul_raise_ct_refresh_event; diff --git a/modules/usrloc/usrloc.h b/modules/usrloc/usrloc.h index 4ae6c972f39..c6fd73f49a6 100644 --- a/modules/usrloc/usrloc.h +++ b/modules/usrloc/usrloc.h @@ -326,6 +326,15 @@ typedef struct usrloc_api { */ void (*free_ucontact_coords) (ucontact_coords coords); + /** + * Check if an ucontact is logically owned by the current OpenSIPS node. + * Always returns true in single node setups or if a contact does not have + * an ownership tag attached. + * + * Return: 1 (true), 0 (false) + */ + int (*is_my_ucontact) (ucontact_t *c); + /** * Generate the next contact ID of a given record. Returns a different * contact ID on each new call, rotating across CLABEL_MASK values.