the function will check the timer routes from the current process, * so be carefull where you are running it from */
| 327 | /* the function will check the timer routes from the current process, |
| 328 | * so be carefull where you are running it from */ |
| 329 | int register_route_timers(void) |
| 330 | { |
| 331 | struct timer_route_param *tr_param; |
| 332 | struct os_timer *t, *p; |
| 333 | int i; |
| 334 | |
| 335 | #define move_to_pending( _t) \ |
| 336 | while(_t) { \ |
| 337 | p = (_t)->next; \ |
| 338 | if ((_t)->trigger_time) { \ |
| 339 | (_t)->next = *tr_timer_pending; \ |
| 340 | *tr_timer_pending = (_t); \ |
| 341 | } else { \ |
| 342 | shm_free( (_t)->t_param ); \ |
| 343 | shm_free( (_t) ); \ |
| 344 | } \ |
| 345 | (_t) = p; \ |
| 346 | } |
| 347 | |
| 348 | lock_get(tr_list_lock); |
| 349 | |
| 350 | /* handle the pending list, remove whatever already finished, |
| 351 | * otherwise put back into pending */ |
| 352 | t = *tr_timer_pending; |
| 353 | *tr_timer_pending = NULL; |
| 354 | move_to_pending( t); |
| 355 | |
| 356 | /* handle the existing list -> free if done or move to pending if |
| 357 | * the job is still under execution (for sure triggering cannot be |
| 358 | * done anymore as the have the lock here) */ |
| 359 | t = *tr_timer_list; |
| 360 | move_to_pending( t); |
| 361 | *tr_timer_list = NULL; |
| 362 | |
| 363 | /* convert timer routes to jobs */ |
| 364 | for(i = 0; i<TIMER_RT_NO && sroutes->timer[i].a ; i++) |
| 365 | { |
| 366 | LM_DBG("registering timer route [%s] at %d secs\n", |
| 367 | sroutes->timer[i].name, sroutes->timer[i].interval); |
| 368 | |
| 369 | tr_param = (struct timer_route_param*) |
| 370 | shm_malloc( sizeof(struct timer_route_param) ); |
| 371 | if (tr_param==NULL) { |
| 372 | LM_ERR("no more mem, skipping route timer [%s]\n", |
| 373 | sroutes->timer[i].name); |
| 374 | } else { |
| 375 | tr_param->idx = i; |
| 376 | tr_param->version = sroutes->version; |
| 377 | t = new_os_timer( "timer_route", 0, route_timer_f, (void*)tr_param, |
| 378 | sroutes->timer[i].interval); |
| 379 | if (t==NULL) { |
| 380 | LM_ERR("no more mem, skipping route timer [%s]\n", |
| 381 | sroutes->timer[i].name); |
| 382 | } else { |
| 383 | /* insert it into the list*/ |
| 384 | t->next = *tr_timer_list; |
| 385 | *tr_timer_list = t; |
| 386 | } |
no test coverage detected