|
@@ -259,82 +259,85 @@ ucontact_t** expired_contacts = 0;
|
|
* \brief Run timer handler for given domain
|
|
* \brief Run timer handler for given domain
|
|
* \param _d domain
|
|
* \param _d domain
|
|
*/
|
|
*/
|
|
-void mem_timer_udomain(udomain_t* _d) {
|
|
|
|
|
|
+void mem_timer_udomain(udomain_t* _d, int istart, int istep) {
|
|
struct impurecord* ptr, *t;
|
|
struct impurecord* ptr, *t;
|
|
struct ucontact* contact_ptr;
|
|
struct ucontact* contact_ptr;
|
|
unsigned int num_expired_contacts = 0;
|
|
unsigned int num_expired_contacts = 0;
|
|
- int i, n, temp, j;
|
|
|
|
|
|
+ int i, n, temp;
|
|
time_t now;
|
|
time_t now;
|
|
int abort = 0;
|
|
int abort = 0;
|
|
int slot;
|
|
int slot;
|
|
|
|
|
|
now = time(0);
|
|
now = time(0);
|
|
- int numcontacts = contact_list->size*2; //assume we should be ok for each slot to have 2 collisions
|
|
|
|
- if (expired_contacts_size < numcontacts) {
|
|
|
|
- LM_DBG("Changing expired_contacts list size from %d to %d\n", expired_contacts_size, numcontacts);
|
|
|
|
- if (expired_contacts){
|
|
|
|
- pkg_free(expired_contacts);
|
|
|
|
- }
|
|
|
|
- expired_contacts = (ucontact_t**)pkg_malloc(numcontacts*sizeof(ucontact_t**));
|
|
|
|
- if (!expired_contacts) {
|
|
|
|
- LM_ERR("no more pkg mem trying to allocate [%d] bytes\n", numcontacts*sizeof(ucontact_t**));
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- expired_contacts_size = numcontacts;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- //go through contacts first
|
|
|
|
- n = contact_list->max_collisions;
|
|
|
|
- LM_DBG("*** mem_timer_udomain - checking contacts - START ***\n");
|
|
|
|
- for (i=0,j=0; i < contact_list->size; i++) {
|
|
|
|
- lock_contact_slot_i(i);
|
|
|
|
- contact_ptr = contact_list->slot[i].first;
|
|
|
|
- while (contact_ptr) {
|
|
|
|
- if (num_expired_contacts >= numcontacts) {
|
|
|
|
- LM_WARN("we don't have enough space to expire all contacts in this pass - will continue in next pass\n");
|
|
|
|
- abort = 1;
|
|
|
|
- break;
|
|
|
|
|
|
+ if (istart == 0) {
|
|
|
|
+ int numcontacts = contact_list->size*2; //assume we should be ok for each slot to have 2 collisions
|
|
|
|
+ if (expired_contacts_size < numcontacts) {
|
|
|
|
+ LM_DBG("Changing expired_contacts list size from %d to %d\n", expired_contacts_size, numcontacts);
|
|
|
|
+ if (expired_contacts){
|
|
|
|
+ pkg_free(expired_contacts);
|
|
|
|
+ }
|
|
|
|
+ expired_contacts = (ucontact_t**)pkg_malloc(numcontacts*sizeof(ucontact_t**));
|
|
|
|
+ if (!expired_contacts) {
|
|
|
|
+ LM_ERR("no more pkg mem trying to allocate [%lu] bytes\n", numcontacts*sizeof(ucontact_t**));
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- LM_DBG("We have a [3gpp=%d] contact in the new contact list in slot %d = [%.*s] (%.*s) which expires in %lf seconds and has a ref count of %d (state: %d)\n",
|
|
|
|
- contact_ptr->is_3gpp, i, contact_ptr->aor.len, contact_ptr->aor.s, contact_ptr->c.len, contact_ptr->c.s,
|
|
|
|
- (double) contact_ptr->expires - now, contact_ptr->ref_count,
|
|
|
|
- contact_ptr->state);
|
|
|
|
- //contacts are now deleted during impurecord processing
|
|
|
|
- if ((contact_ptr->expires-now) <= 0) {
|
|
|
|
- if (contact_ptr->state == CONTACT_DELAYED_DELETE) {
|
|
|
|
- if (contact_ptr->ref_count <= 0) {
|
|
|
|
- LM_DBG("contact in state CONTACT_DELATED_DELETE is about to be deleted");
|
|
|
|
|
|
+ expired_contacts_size = numcontacts;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //go through contacts first
|
|
|
|
+ n = contact_list->max_collisions;
|
|
|
|
+ LM_DBG("*** mem_timer_udomain - checking contacts - START ***\n");
|
|
|
|
+ for (i=0; i < contact_list->size; i++) {
|
|
|
|
+ lock_contact_slot_i(i);
|
|
|
|
+ contact_ptr = contact_list->slot[i].first;
|
|
|
|
+ while (contact_ptr) {
|
|
|
|
+ if (num_expired_contacts >= numcontacts) {
|
|
|
|
+ LM_WARN("we don't have enough space to expire all contacts in this pass - will continue in next pass\n");
|
|
|
|
+ abort = 1;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ LM_DBG("We have a [3gpp=%d] contact in the new contact list in slot %d = [%.*s] (%.*s) which expires in %lf seconds and has a ref count of %d (state: %d)\n",
|
|
|
|
+ contact_ptr->is_3gpp, i, contact_ptr->aor.len, contact_ptr->aor.s, contact_ptr->c.len, contact_ptr->c.s,
|
|
|
|
+ (double) contact_ptr->expires - now, contact_ptr->ref_count,
|
|
|
|
+ contact_ptr->state);
|
|
|
|
+ //contacts are now deleted during impurecord processing
|
|
|
|
+ if ((contact_ptr->expires-now) <= 0) {
|
|
|
|
+ if (contact_ptr->state == CONTACT_DELAYED_DELETE) {
|
|
|
|
+ if (contact_ptr->ref_count <= 0) {
|
|
|
|
+ LM_DBG("contact in state CONTACT_DELATED_DELETE is about to be deleted");
|
|
|
|
+ expired_contacts[num_expired_contacts] = contact_ptr;
|
|
|
|
+ num_expired_contacts++;
|
|
|
|
+ } else {
|
|
|
|
+ LM_DBG("contact in state CONTACT_DELATED_DELETE still has a ref count of [%d]... not doing anything for now\n", contact_ptr->ref_count);
|
|
|
|
+ }
|
|
|
|
+ } else if (contact_ptr->state != CONTACT_DELETED) {
|
|
|
|
+ LM_DBG("expiring contact [%.*s].... setting to CONTACT_EXPIRE_PENDING_NOTIFY\n", contact_ptr->aor.len, contact_ptr->aor.s);
|
|
|
|
+ contact_ptr->state = CONTACT_EXPIRE_PENDING_NOTIFY;
|
|
|
|
+ ref_contact_unsafe(contact_ptr);
|
|
expired_contacts[num_expired_contacts] = contact_ptr;
|
|
expired_contacts[num_expired_contacts] = contact_ptr;
|
|
num_expired_contacts++;
|
|
num_expired_contacts++;
|
|
- } else {
|
|
|
|
- LM_DBG("contact in state CONTACT_DELATED_DELETE still has a ref count of [%d]... not doing anything for now\n", contact_ptr->ref_count);
|
|
|
|
}
|
|
}
|
|
- } else if (contact_ptr->state != CONTACT_DELETED) {
|
|
|
|
- LM_DBG("expiring contact [%.*s].... setting to CONTACT_EXPIRE_PENDING_NOTIFY\n", contact_ptr->aor.len, contact_ptr->aor.s);
|
|
|
|
- contact_ptr->state = CONTACT_EXPIRE_PENDING_NOTIFY;
|
|
|
|
- ref_contact_unsafe(contact_ptr);
|
|
|
|
- expired_contacts[num_expired_contacts] = contact_ptr;
|
|
|
|
- num_expired_contacts++;
|
|
|
|
}
|
|
}
|
|
|
|
+ contact_ptr = contact_ptr->next;
|
|
|
|
+ }
|
|
|
|
+ if (contact_list->slot[i].n > n) {
|
|
|
|
+ n = contact_list->slot[i].n;
|
|
|
|
+ }
|
|
|
|
+ unlock_contact_slot_i(i);
|
|
|
|
+ contact_list->max_collisions = n;
|
|
|
|
+ if (abort == 1) {
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
- contact_ptr = contact_ptr->next;
|
|
|
|
- }
|
|
|
|
- if (contact_list->slot[i].n > n) {
|
|
|
|
- n = contact_list->slot[i].n;
|
|
|
|
- }
|
|
|
|
- unlock_contact_slot_i(i);
|
|
|
|
- contact_list->max_collisions = n;
|
|
|
|
- if (abort == 1) {
|
|
|
|
- break;
|
|
|
|
}
|
|
}
|
|
|
|
+ LM_DBG("*** mem_timer_udomain - checking contacts - FINISHED ***\n");
|
|
}
|
|
}
|
|
- LM_DBG("*** mem_timer_udomain - checking contacts - FINISHED ***\n");
|
|
|
|
-
|
|
|
|
|
|
+
|
|
temp = 0;
|
|
temp = 0;
|
|
n = _d->max_collisions;
|
|
n = _d->max_collisions;
|
|
|
|
|
|
LM_DBG("*** mem_timer_udomain - checking IMPUs - START ***\n");
|
|
LM_DBG("*** mem_timer_udomain - checking IMPUs - START ***\n");
|
|
- for (i = 0; i < _d->size; i++) {
|
|
|
|
|
|
+ for (i = istart; i < _d->size; i+=istep) {
|
|
lock_ulslot(_d, i);
|
|
lock_ulslot(_d, i);
|
|
ptr = _d->table[i].first;
|
|
ptr = _d->table[i].first;
|
|
temp = 0;
|
|
temp = 0;
|
|
@@ -360,29 +363,31 @@ void mem_timer_udomain(udomain_t* _d) {
|
|
}
|
|
}
|
|
LM_DBG("*** mem_timer_udomain - checking IMPUs - FINISHED ***\n");
|
|
LM_DBG("*** mem_timer_udomain - checking IMPUs - FINISHED ***\n");
|
|
|
|
|
|
- n = ims_subscription_list->max_collisions;
|
|
|
|
- for (i = 0; i < ims_subscription_list->size; i++) {
|
|
|
|
- lock_subscription_slot(i);
|
|
|
|
- if (ims_subscription_list->slot[i].n > n) {
|
|
|
|
- n = ims_subscription_list->slot[i].n;
|
|
|
|
|
|
+ if (istart == 0) {
|
|
|
|
+ n = ims_subscription_list->max_collisions;
|
|
|
|
+ for (i = 0; i < ims_subscription_list->size; i++) {
|
|
|
|
+ lock_subscription_slot(i);
|
|
|
|
+ if (ims_subscription_list->slot[i].n > n) {
|
|
|
|
+ n = ims_subscription_list->slot[i].n;
|
|
|
|
+ }
|
|
|
|
+ unlock_subscription_slot(i);
|
|
}
|
|
}
|
|
- unlock_subscription_slot(i);
|
|
|
|
- }
|
|
|
|
- ims_subscription_list->max_collisions = n;
|
|
|
|
-
|
|
|
|
- /* now we delete the expired contacts. (mark them for deletion */
|
|
|
|
- for (i=0; i<num_expired_contacts; i++) {
|
|
|
|
- slot = expired_contacts[i]->sl;
|
|
|
|
- lock_contact_slot_i(slot);
|
|
|
|
- if (expired_contacts[i]->state != CONTACT_DELAYED_DELETE) {
|
|
|
|
- LM_DBG("Setting contact state to CONTACT_DELETED for contact [%.*s]\n", expired_contacts[i]->aor.len, expired_contacts[i]->aor.s);
|
|
|
|
- expired_contacts[i]->state = CONTACT_DELETED;
|
|
|
|
- unref_contact_unsafe(expired_contacts[i]);
|
|
|
|
- } else {
|
|
|
|
- LM_DBG("deleting contact [%.*s]\n", expired_contacts[i]->aor.len, expired_contacts[i]->aor.s);
|
|
|
|
- delete_scontact(expired_contacts[i]);
|
|
|
|
|
|
+ ims_subscription_list->max_collisions = n;
|
|
|
|
+
|
|
|
|
+ /* now we delete the expired contacts. (mark them for deletion */
|
|
|
|
+ for (i=0; i<num_expired_contacts; i++) {
|
|
|
|
+ slot = expired_contacts[i]->sl;
|
|
|
|
+ lock_contact_slot_i(slot);
|
|
|
|
+ if (expired_contacts[i]->state != CONTACT_DELAYED_DELETE) {
|
|
|
|
+ LM_DBG("Setting contact state to CONTACT_DELETED for contact [%.*s]\n", expired_contacts[i]->aor.len, expired_contacts[i]->aor.s);
|
|
|
|
+ expired_contacts[i]->state = CONTACT_DELETED;
|
|
|
|
+ unref_contact_unsafe(expired_contacts[i]);
|
|
|
|
+ } else {
|
|
|
|
+ LM_DBG("deleting contact [%.*s]\n", expired_contacts[i]->aor.len, expired_contacts[i]->aor.s);
|
|
|
|
+ delete_scontact(expired_contacts[i]);
|
|
|
|
+ }
|
|
|
|
+ unlock_contact_slot_i(slot);
|
|
}
|
|
}
|
|
- unlock_contact_slot_i(slot);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|