|
@@ -42,9 +42,6 @@
|
|
#include "dlg_req_within.h"
|
|
#include "dlg_req_within.h"
|
|
#include "dlg_db_handler.h"
|
|
#include "dlg_db_handler.h"
|
|
|
|
|
|
-#define MAX_LDG_LOCKS 2048
|
|
|
|
-#define MIN_LDG_LOCKS 2
|
|
|
|
-
|
|
|
|
extern int dlg_ka_interval;
|
|
extern int dlg_ka_interval;
|
|
|
|
|
|
/*! global dialog table */
|
|
/*! global dialog table */
|
|
@@ -223,7 +220,7 @@ int dlg_clean_run(ticks_t ti)
|
|
tm = (unsigned int)time(NULL);
|
|
tm = (unsigned int)time(NULL);
|
|
for(i=0; i<d_table->size; i++)
|
|
for(i=0; i<d_table->size; i++)
|
|
{
|
|
{
|
|
- lock_set_get(d_table->locks, d_table->entries[i].lock_idx);
|
|
|
|
|
|
+ dlg_lock(d_table, &d_table->entries[i]);
|
|
dlg = d_table->entries[i].first;
|
|
dlg = d_table->entries[i].first;
|
|
while (dlg) {
|
|
while (dlg) {
|
|
tdlg = dlg;
|
|
tdlg = dlg;
|
|
@@ -243,7 +240,7 @@ int dlg_clean_run(ticks_t ti)
|
|
tdlg->dflags |= DLG_FLAG_CHANGED;
|
|
tdlg->dflags |= DLG_FLAG_CHANGED;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- lock_set_release(d_table->locks, d_table->entries[i].lock_idx);
|
|
|
|
|
|
+ dlg_unlock(d_table, &d_table->entries[i]);
|
|
}
|
|
}
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -288,30 +285,13 @@ int init_dlg_table(unsigned int size)
|
|
d_table->size = size;
|
|
d_table->size = size;
|
|
d_table->entries = (struct dlg_entry*)(d_table+1);
|
|
d_table->entries = (struct dlg_entry*)(d_table+1);
|
|
|
|
|
|
- n = (size<MAX_LDG_LOCKS)?size:MAX_LDG_LOCKS;
|
|
|
|
- for( ; n>=MIN_LDG_LOCKS ; n-- ) {
|
|
|
|
- d_table->locks = lock_set_alloc(n);
|
|
|
|
- if (d_table->locks==0)
|
|
|
|
- continue;
|
|
|
|
- if (lock_set_init(d_table->locks)==0) {
|
|
|
|
- lock_set_dealloc(d_table->locks);
|
|
|
|
- d_table->locks = 0;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- d_table->locks_no = n;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (d_table->locks==0) {
|
|
|
|
- LM_ERR("unable to allocted at least %d locks for the hash table\n",
|
|
|
|
- MIN_LDG_LOCKS);
|
|
|
|
- goto error1;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
for( i=0 ; i<size; i++ ) {
|
|
for( i=0 ; i<size; i++ ) {
|
|
memset( &(d_table->entries[i]), 0, sizeof(struct dlg_entry) );
|
|
memset( &(d_table->entries[i]), 0, sizeof(struct dlg_entry) );
|
|
|
|
+ if(lock_init(&d_table->entries[i].lock)<0) {
|
|
|
|
+ LM_ERR("failed to init lock for slot: %d\n", i);
|
|
|
|
+ goto error1;
|
|
|
|
+ }
|
|
d_table->entries[i].next_id = rand() % (3*size);
|
|
d_table->entries[i].next_id = rand() % (3*size);
|
|
- d_table->entries[i].lock_idx = i % d_table->locks_no;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -411,11 +391,6 @@ void destroy_dlg_table(void)
|
|
if (d_table==0)
|
|
if (d_table==0)
|
|
return;
|
|
return;
|
|
|
|
|
|
- if (d_table->locks) {
|
|
|
|
- lock_set_destroy(d_table->locks);
|
|
|
|
- lock_set_dealloc(d_table->locks);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
for( i=0 ; i<d_table->size; i++ ) {
|
|
for( i=0 ; i<d_table->size; i++ ) {
|
|
dlg = d_table->entries[i].first;
|
|
dlg = d_table->entries[i].first;
|
|
while (dlg) {
|
|
while (dlg) {
|
|
@@ -423,7 +398,7 @@ void destroy_dlg_table(void)
|
|
dlg = dlg->next;
|
|
dlg = dlg->next;
|
|
destroy_dlg(l_dlg);
|
|
destroy_dlg(l_dlg);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ lock_destroy(&d_table->entries[i].lock);
|
|
}
|
|
}
|
|
|
|
|
|
shm_free(d_table);
|
|
shm_free(d_table);
|