s_persistency.h File Reference


Detailed Description

S-CSCF persistency operations.

Author:
Dragos Vingarzan vingarzan -at- fokus dot fraunhofer dot de

Definition in file s_persistency.h.

#include "bin_scscf.h"

Go to the source code of this file.

Enumerations

enum  data_type_t {
  P_REGISTRAR = 1, P_DIALOGS = 2, P_SUBSCRIPTIONS = 3, S_AUTH = 4,
  S_DIALOGS = 5, S_REGISTRAR = 6
}

Functions

int make_snapshot_authdata ()
 Creates a snapshots of the authorization data and then calls the dumping function.
int load_snapshot_authdata ()
 Loads the authorization data from the last snapshot.
void persistency_timer_authdata (unsigned int ticks, void *param)
 Timer callback for persistency dumps.
int make_snapshot_dialogs ()
 Creates a snapshots of the dialogs data and then calls the dumping function.
int load_snapshot_dialogs ()
 Loads the dialogs data from the last snapshot.
void persistency_timer_dialogs (unsigned int ticks, void *param)
 Timer callback for persistency dumps.
int make_snapshot_registrar ()
 Creates a snapshots of the registrar and then calls the dumping function.
int load_snapshot_registrar ()
 Loads the registrar data from the last snapshot.
void persistency_timer_registrar (unsigned int ticks, void *param)
 Timer callback for persistency dumps.


Enumeration Type Documentation

enum data_type_t

Enumerator:
P_REGISTRAR 
P_DIALOGS 
P_SUBSCRIPTIONS 
S_AUTH 
S_DIALOGS 
S_REGISTRAR 

Definition at line 62 of file s_persistency.h.

00062              {
00063     S_AUTH=4,
00064     S_DIALOGS=5,
00065     S_REGISTRAR=6
00066 } data_type_t;


Function Documentation

int make_snapshot_authdata (  ) 

Creates a snapshots of the authorization data and then calls the dumping function.

Returns:
1 on success or 0 on failure

Definition at line 112 of file s_persistency.c.

References auth_data, auth_data_hash_size, auth_data_lock(), auth_data_unlock(), bin_alloc(), bin_encode_auth_userdata(), bin_free(), auth_hash_slot_t::head, _auth_userdata::next, S_AUTH, s_dump(), scscf_persistency_location, scscf_persistency_mode, and WITH_DATABASE_CACHE.

Referenced by mod_destroy(), and persistency_timer_authdata().

00113 {
00114     bin_data x;
00115     auth_userdata *aud;
00116     int i;
00117     
00118     /*In WITH_DATABASE_CACHE mode, serialize each hashtable element separately */
00119     if(scscf_persistency_mode!=WITH_DATABASE_CACHE){    
00120         if (!bin_alloc(&x,256)) goto error;
00121         for(i=0;i<auth_data_hash_size;i++){
00122             auth_data_lock(i);
00123             aud = auth_data[i].head;
00124             while(aud){
00125                 if (!bin_encode_auth_userdata(&x,aud)) goto error;
00126                 aud = aud->next;
00127             }
00128             auth_data_unlock(i);
00129         }
00130         //bin_print(&x);
00131     }
00132     i=s_dump(&x,scscf_persistency_location,"authdata", S_AUTH);
00133     //i = bin_dump(&x,scscf_persistency_mode,scscf_persistency_location,"authdata");        
00134     if(scscf_persistency_mode!=WITH_DATABASE_CACHE){
00135         bin_free(&x);
00136     }
00137     return i;
00138 error:
00139     return 0;
00140 }

int load_snapshot_authdata (  ) 

Loads the authorization data from the last snapshot.

Returns:
1 on success or 0 on failure

Definition at line 147 of file s_persistency.c.

References auth_data, auth_data_lock(), auth_data_unlock(), bin_decode_auth_userdata(), bin_free(), _auth_userdata::hash, auth_hash_slot_t::head, _bin_data::len, M_NAME, _bin_data::max, _auth_userdata::next, _auth_userdata::prev, _auth_userdata::private_identity, S_AUTH, s_load(), scscf_persistency_location, scscf_persistency_mode, auth_hash_slot_t::tail, and WITH_DATABASE_CACHE.

Referenced by mod_init().

00148 {
00149     bin_data x;
00150     auth_userdata *aud;
00151     if (!s_load(&x,scscf_persistency_location,"authdata", S_AUTH)) goto error;
00152     //if (!bin_load(&x,scscf_persistency_mode,scscf_persistency_location,"authdata")) goto error;
00153     
00154     if(scscf_persistency_mode!=WITH_DATABASE_CACHE){
00155         //bin_print(&x);
00156         x.max=0;
00157         LOG(L_INFO,"INFO:"M_NAME":load_snapshot_auth: max %d len %d\n",x.max,x.len);
00158         while(x.max<x.len){
00159             aud = bin_decode_auth_userdata(&x);     
00160             if (!aud) return 0;
00161             LOG(L_INFO,"INFO:"M_NAME":load_snapshot_auth: Loaded auth_userdata for <%.*s>\n",aud->private_identity.len,aud->private_identity.s);
00162             auth_data_lock(aud->hash);
00163             aud->prev = auth_data[aud->hash].tail;
00164             aud->next = 0;
00165             if (auth_data[aud->hash].tail) auth_data[aud->hash].tail->next = aud;
00166             auth_data[aud->hash].tail = aud;
00167             if (!auth_data[aud->hash].head) auth_data[aud->hash].head = aud;
00168             auth_data_unlock(aud->hash);
00169         }
00170         bin_free(&x);
00171     }
00172     return 1;
00173 error:
00174     return 0;
00175 }

void persistency_timer_authdata ( unsigned int  ticks,
void *  param 
)

Timer callback for persistency dumps.

Parameters:
ticks - what's the time
param - a given parameter to be called with

Definition at line 182 of file s_persistency.c.

References auth_snapshot_version, and make_snapshot_authdata().

Referenced by mod_init().

00183 {
00184     make_snapshot_authdata();
00185     
00186     if (auth_snapshot_version) (*auth_snapshot_version)++;  
00187 }

int make_snapshot_dialogs (  ) 

Creates a snapshots of the dialogs data and then calls the dumping function.

Returns:
1 on success or 0 on failure

Definition at line 104 of file p_persistency.c.

References bin_alloc(), bin_encode_p_dialog(), bin_encode_s_dialog(), bin_free(), d_lock(), d_unlock(), s_dialog_hash_slot::head, p_dialog_hash_slot::head, _s_dialog::next, _p_dialog::next, P_DIALOGS, p_dialogs, p_dialogs_hash_size, p_dump(), pcscf_persistency_location, pcscf_persistency_mode, s_dialogs, S_DIALOGS, s_dialogs_hash_size, s_dump(), scscf_persistency_location, scscf_persistency_mode, and WITH_DATABASE_CACHE.

00105 {
00106     bin_data x;
00107     p_dialog *d;
00108     int i;  
00109     
00110     /*In WITH_DATABASE_CACHE mode, serialize each hashtable element separately */
00111     if(pcscf_persistency_mode!=WITH_DATABASE_CACHE){
00112         if (!bin_alloc(&x,256)) goto error;     
00113         for(i=0;i<p_dialogs_hash_size;i++){
00114             d_lock(i);
00115             d = p_dialogs[i].head;
00116             while(d){
00117                 if (!bin_encode_p_dialog(&x,d)) goto error;
00118                 d = d->next;
00119             }
00120             d_unlock(i);
00121         }
00122         //bin_print(&x);
00123     }
00124     i = p_dump(&x,pcscf_persistency_location,"pdialogs", P_DIALOGS);
00125     //i = bin_dump(&x,pcscf_persistency_mode,pcscf_persistency_location,"pdialogs");
00126     if(pcscf_persistency_mode!=WITH_DATABASE_CACHE){        
00127         bin_free(&x);
00128     }
00129     return i;
00130 error:
00131     return 0;
00132 }  

int load_snapshot_dialogs (  ) 

Loads the dialogs data from the last snapshot.

Returns:
1 on success or 0 on failure

Definition at line 138 of file p_persistency.c.

References _s_dialog::aor, bin_decode_p_dialog(), bin_decode_s_dialog(), bin_free(), d_lock(), d_unlock(), _s_dialog::hash, _p_dialog::hash, s_dialog_hash_slot::head, p_dialog_hash_slot::head, _p_dialog::host, _bin_data::len, M_NAME, _bin_data::max, _s_dialog::next, _p_dialog::next, p_dialogs, P_DIALOGS, p_load(), pcscf_persistency_location, pcscf_persistency_mode, _s_dialog::prev, _p_dialog::prev, S_DIALOGS, s_dialogs, s_load(), scscf_persistency_location, scscf_persistency_mode, s_dialog_hash_slot::tail, p_dialog_hash_slot::tail, and WITH_DATABASE_CACHE.

00139 {
00140     bin_data x;
00141     p_dialog *d;
00142     
00143     if (!p_load(&x,pcscf_persistency_location,"pdialogs",P_DIALOGS)) goto error;
00144     //if (!bin_load(&x,pcscf_persistency_mode,pcscf_persistency_location,"pdialogs")) goto error;
00145     
00146     if(pcscf_persistency_mode!=WITH_DATABASE_CACHE){
00147         //bin_print(&x);
00148         x.max=0;
00149         LOG(L_INFO,"INFO:"M_NAME":load_snapshot_dlg: max %d len %d\n",x.max,x.len);
00150         while(x.max<x.len){
00151             d = bin_decode_p_dialog(&x);
00152             if (!d) return 0;
00153             LOG(L_INFO,"INFO:"M_NAME":load_snapshot_dlg: Loaded p_dialog for <%.*s>\n",d->host.len,d->host.s);
00154             d_lock(d->hash);
00155             d->prev = p_dialogs[d->hash].tail;
00156             d->next = 0;
00157             if (p_dialogs[d->hash].tail) p_dialogs[d->hash].tail->next = d;
00158             p_dialogs[d->hash].tail = d;
00159             if (!p_dialogs[d->hash].head) p_dialogs[d->hash].head = d;
00160             d_unlock(d->hash);
00161         }
00162         bin_free(&x);
00163     }
00164     return 1;
00165 error:
00166     return 0;
00167     
00168 }

void persistency_timer_dialogs ( unsigned int  ticks,
void *  param 
)

Timer callback for persistency dumps.

Parameters:
ticks - what's the time
param - a given parameter to be called with

Definition at line 176 of file p_persistency.c.

References dialogs_snapshot_version, and make_snapshot_dialogs().

00177 {
00178     make_snapshot_dialogs();
00179     
00180     if(dialogs_snapshot_version) (*dialogs_snapshot_version)++;         
00181 }

int make_snapshot_registrar (  ) 

Creates a snapshots of the registrar and then calls the dumping function.

Returns:
1 on success or 0 on failure

Definition at line 192 of file p_persistency.c.

References bin_alloc(), bin_encode_r_contact(), bin_encode_r_public(), bin_free(), r_hash_slot::head, _r_public::next, _r_contact::next, p_dump(), P_REGISTRAR, pcscf_persistency_location, pcscf_persistency_mode, r_hash_size, r_lock(), r_unlock(), registrar, s_dump(), S_REGISTRAR, scscf_persistency_location, scscf_persistency_mode, and WITH_DATABASE_CACHE.

00193 {
00194     bin_data x;
00195     r_contact *c;
00196     int i;  
00197     
00198     /*In WITH_DATABASE_CACHE mode, serialize each hashtable element separately */
00199     if(pcscf_persistency_mode!=WITH_DATABASE_CACHE){
00200         if (!bin_alloc(&x,256)) goto error;     
00201         for(i=0;i<r_hash_size;i++){
00202             r_lock(i);
00203             c = registrar[i].head;
00204             while(c){
00205                 if (!bin_encode_r_contact(&x,c)) goto error;
00206                 c = c->next;
00207             }
00208             r_unlock(i);
00209         }
00210         //bin_print(&x);
00211     }
00212     i = p_dump(&x,pcscf_persistency_location,"pregistrar", P_REGISTRAR);
00213     //i = bin_dump(&x,pcscf_persistency_mode,pcscf_persistency_location,"pregistrar");
00214     if(pcscf_persistency_mode!=WITH_DATABASE_CACHE){        
00215         bin_free(&x);
00216     }
00217     return i;
00218 error:
00219     return 0;
00220 }  

int load_snapshot_registrar (  ) 

Loads the registrar data from the last snapshot.

Returns:
1 on success or 0 on failure

Definition at line 226 of file p_persistency.c.

References _r_public::aor, bin_decode_r_contact(), bin_decode_r_public(), bin_free(), _r_public::hash, _r_contact::hash, r_hash_slot::head, _bin_data::len, M_NAME, _bin_data::max, _r_public::next, _r_contact::next, p_load(), P_REGISTRAR, pcscf_persistency_location, pcscf_persistency_mode, _r_public::prev, _r_contact::prev, r_lock(), r_unlock(), registrar, s_load(), S_REGISTRAR, scscf_persistency_location, scscf_persistency_mode, r_hash_slot::tail, _r_contact::uri, and WITH_DATABASE_CACHE.

00227 {
00228     bin_data x;
00229     r_contact *c;
00230     
00231     if (!p_load(&x,pcscf_persistency_location,"pregistrar",P_REGISTRAR)) goto error;
00232     //if (!bin_load(&x,pcscf_persistency_mode,pcscf_persistency_location,"pregistrar")) goto error;
00233     
00234     if(pcscf_persistency_mode!=WITH_DATABASE_CACHE){
00235         //bin_print(&x);
00236         x.max=0;
00237         LOG(L_INFO,"INFO:"M_NAME":load_snapshot_registrar: max %d len %d\n",x.max,x.len);
00238         while(x.max<x.len){
00239             c = bin_decode_r_contact(&x);
00240             if (!c) return 0;
00241             LOG(L_INFO,"INFO:"M_NAME":load_snapshot_registrar: Loaded r_contact for <%.*s>\n",c->uri.len,c->uri.s);
00242             r_lock(c->hash);
00243             c->prev = registrar[c->hash].tail;
00244             c->next = 0;
00245             if (registrar[c->hash].tail) registrar[c->hash].tail->next = c;
00246             registrar[c->hash].tail = c;
00247             if (!registrar[c->hash].head) registrar[c->hash].head = c;
00248             r_unlock(c->hash);
00249         }
00250         bin_free(&x);
00251     }
00252     return 1;
00253 error:
00254     return 0;
00255     
00256 }

void persistency_timer_registrar ( unsigned int  ticks,
void *  param 
)

Timer callback for persistency dumps.

Parameters:
ticks - what's the time
param - a given parameter to be called with

Definition at line 264 of file p_persistency.c.

References make_snapshot_registrar(), and registrar_snapshot_version.

00265 {
00266     make_snapshot_registrar();   
00267     
00268     if(registrar_snapshot_version) (*registrar_snapshot_version)++; 
00269 }


Generated on Thu Oct 23 04:14:45 2008 for Open IMS Core CSCFs by  doxygen 1.5.2