MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / trie_reload_data_head

Function trie_reload_data_head

modules/trie/trie.c:254–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252 */
253
254static inline int trie_reload_data_head(struct head_db *hd,
255 str *part_name, int initial)
256{
257 trie_data_t *new_data;
258 trie_data_t *old_data;
259 time_t rawtime;
260 MD5_CTX Md5Ctx;
261 HASH bin_md5;
262 FILE *fp=NULL;
263
264 if (no_concurrent_reload) {
265 lock_get( hd->ref_lock->lock );
266 if (hd->ongoing_reload) {
267 lock_release( hd->ref_lock->lock );
268 LM_WARN("Reload already in progress, discarding this one\n");
269 return -2;
270 }
271 hd->ongoing_reload = 1;
272 lock_release( hd->ref_lock->lock );
273 }
274
275 LM_INFO("loading trie data in partition %.*s\n",part_name->len,part_name->s);
276 MD5Init(&Md5Ctx);
277
278 new_data = trie_load_info(hd, &Md5Ctx, fp);
279 if ( new_data==0 ) {
280 LM_CRIT("failed to load routing info\n");
281 goto error;
282 }
283
284 lock_start_write( hd->ref_lock );
285
286 /* no more activ readers -> do the swapping */
287 old_data = hd->rdata;
288 hd->rdata = new_data;
289 /* update the time of the last reload for the current partition */
290 time(&rawtime);
291
292 hd->time_last_update = rawtime;
293
294 MD5Final(bin_md5, &Md5Ctx);
295 bin_hash_to_hex(bin_md5,hd->md5);
296
297 lock_stop_write( (hd->ref_lock) );
298
299 LM_INFO("loaded trie data in partition %.*s\n",part_name->len,part_name->s);
300
301 /* destroy old data */
302 if (old_data) {
303 /* free old data */
304 free_trie_data(old_data, hd->free);
305 }
306 LM_INFO("destroyed old trie data in partition %.*s\n",part_name->len,part_name->s);
307
308 if (no_concurrent_reload)
309 hd->ongoing_reload = 0;
310 return 0;
311

Callers 2

trie_reload_dataFunction · 0.85
trie_reload_cmd_1Function · 0.85

Calls 7

lock_getFunction · 0.85
lock_releaseFunction · 0.85
MD5InitFunction · 0.85
trie_load_infoFunction · 0.85
MD5FinalFunction · 0.85
free_trie_dataFunction · 0.85
bin_hash_to_hexFunction · 0.70

Tested by

no test coverage detected