Definition in file p_persistency.h.
#include "bin_pcscf.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_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. | |
| int | make_snapshot_subscriptions () |
| Creates a snapshots of the subscriptions and then calls the dumping function. | |
| int | load_snapshot_subscriptions () |
| Loads the subscriptions data from the last snapshot. | |
| void | persistency_timer_subscriptions (unsigned int ticks, void *param) |
| Timer callback for persistency dumps. | |
| enum data_type_t |
Definition at line 62 of file p_persistency.h.
00062 { 00063 P_REGISTRAR=1, 00064 P_DIALOGS=2, 00065 P_SUBSCRIPTIONS=3 00066 } data_type_t;
| int make_snapshot_dialogs | ( | ) |
Creates a snapshots of the dialogs data and then calls the dumping function.
Definition at line 104 of file p_persistency.c.
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.
Definition at line 138 of file p_persistency.c.
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.
| ticks | - what's the time | |
| param | - a given parameter to be called with |
Definition at line 176 of file p_persistency.c.
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.
Definition at line 192 of file p_persistency.c.
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.
Definition at line 226 of file p_persistency.c.
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.
| ticks | - what's the time | |
| param | - a given parameter to be called with |
Definition at line 264 of file p_persistency.c.
00265 { 00266 make_snapshot_registrar(); 00267 00268 if(registrar_snapshot_version) (*registrar_snapshot_version)++; 00269 }
| int make_snapshot_subscriptions | ( | ) |
Creates a snapshots of the subscriptions and then calls the dumping function.
Definition at line 282 of file p_persistency.c.
References bin_alloc(), bin_encode_r_subscription(), bin_free(), r_subscription_hash_slot::head, _r_subscription::next, p_dump(), P_SUBSCRIPTIONS, pcscf_persistency_location, pcscf_persistency_mode, subs_lock(), subs_unlock(), subscriptions, subscriptions_hash_size, and WITH_DATABASE_CACHE.
Referenced by mod_destroy(), and persistency_timer_subscriptions().
00283 { 00284 bin_data x; 00285 r_subscription *s; 00286 int i; 00287 00288 /*In WITH_DATABASE_CACHE mode, serialize each hashtable element separately */ 00289 if(pcscf_persistency_mode!=WITH_DATABASE_CACHE){ 00290 if (!bin_alloc(&x,256)) goto error; 00291 for(i=0;i<subscriptions_hash_size;i++){ 00292 subs_lock(i); 00293 s = subscriptions[i].head; 00294 while(s){ 00295 if (!bin_encode_r_subscription(&x,s)) goto error; 00296 s = s->next; 00297 } 00298 subs_unlock(i); 00299 } 00300 //bin_print(&x); 00301 } 00302 i = p_dump(&x,pcscf_persistency_location,"psubscriptions", P_SUBSCRIPTIONS); 00303 //i = bin_dump(&x,pcscf_persistency_mode,pcscf_persistency_location,"psubscriptions"); 00304 if(pcscf_persistency_mode!=WITH_DATABASE_CACHE){ 00305 bin_free(&x); 00306 } 00307 return i; 00308 error: 00309 return 0; 00310 }
| int load_snapshot_subscriptions | ( | ) |
Loads the subscriptions data from the last snapshot.
Definition at line 316 of file p_persistency.c.
References bin_decode_r_subscription(), bin_free(), _r_subscription::hash, r_subscription_hash_slot::head, _bin_data::len, M_NAME, _bin_data::max, _r_subscription::next, p_load(), P_SUBSCRIPTIONS, pcscf_persistency_location, pcscf_persistency_mode, _r_subscription::prev, _r_subscription::req_uri, subs_lock(), subs_unlock(), subscriptions, r_subscription_hash_slot::tail, and WITH_DATABASE_CACHE.
Referenced by mod_init().
00317 { 00318 bin_data x; 00319 r_subscription *s; 00320 00321 if (!p_load(&x,pcscf_persistency_location,"psubscriptions",P_SUBSCRIPTIONS)) goto error; 00322 //if (!bin_load(&x,pcscf_persistency_mode,pcscf_persistency_location,"psubscriptions")) goto error; 00323 00324 if(pcscf_persistency_mode!=WITH_DATABASE_CACHE){ 00325 //bin_print(&x); 00326 x.max=0; 00327 LOG(L_INFO,"INFO:"M_NAME":load_snapshot_subscriptions: max %d len %d\n",x.max,x.len); 00328 while(x.max<x.len){ 00329 s = bin_decode_r_subscription(&x); 00330 if (!s) return 0; 00331 LOG(L_INFO,"INFO:"M_NAME":load_snapshot_subscriptions: Loaded r_subscription for <%.*s>\n",s->req_uri.len,s->req_uri.s); 00332 subs_lock(s->hash); 00333 s->prev = subscriptions[s->hash].tail; 00334 s->next = 0; 00335 if (subscriptions[s->hash].tail) subscriptions[s->hash].tail->next = s; 00336 subscriptions[s->hash].tail = s; 00337 if (!subscriptions[s->hash].head) subscriptions[s->hash].head = s; 00338 subs_unlock(s->hash); 00339 } 00340 bin_free(&x); 00341 } 00342 return 1; 00343 error: 00344 return 0; 00345 00346 }
| void persistency_timer_subscriptions | ( | unsigned int | ticks, | |
| void * | param | |||
| ) |
Timer callback for persistency dumps.
| ticks | - what's the time | |
| param | - a given parameter to be called with |
Definition at line 354 of file p_persistency.c.
References make_snapshot_subscriptions(), and subs_snapshot_version.
Referenced by mod_init().
00355 { 00356 make_snapshot_subscriptions(); 00357 00358 if(subs_snapshot_version) (*subs_snapshot_version)++; 00359 }
1.5.2