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

Function check_and_split_time_list

modules/tm/timer.c:841–894  ·  view source on GitHub ↗

detach items passed by the time from timer list */

Source from the content-addressed store, hash-verified

839
840/* detach items passed by the time from timer list */
841static struct timer_link *check_and_split_time_list( struct timer *timer_list,
842 utime_t time )
843{
844 struct timer_link *tl , *end, *ret;
845
846
847 /* quick check whether it is worth entering the lock */
848 if (timer_list->first_tl.next_tl==&timer_list->last_tl
849 || ( /* timer_list->first_tl.next_tl
850 && */ timer_list->first_tl.next_tl->time_out > time) )
851 return NULL;
852
853 /* the entire timer list is locked now -- no one else can manipulate it */
854 lock(timer_list->mutex);
855
856#ifdef TM_TIMER_DEBUG
857 check_timer_list( timer_list, "before split" );
858#endif
859 end = &timer_list->last_tl;
860 tl = timer_list->first_tl.next_tl;
861 while( tl!=end && tl->time_out <= time)
862 tl=tl->ld_tl->next_tl;
863
864 /* nothing to delete found */
865 if (tl->prev_tl==&(timer_list->first_tl)) {
866 ret = NULL;
867 } else { /* we did find timers to be fired! */
868 /* the detached list begins with current beginning */
869 ret = timer_list->first_tl.next_tl;
870 /* and we mark the end of the split list */
871 tl->prev_tl->next_tl = NULL;
872 /* the shortened list starts from where we suspended */
873 timer_list->first_tl.next_tl = tl;
874 tl->prev_tl = & timer_list->first_tl;
875
876 for( tl=ret ; tl ; tl=tl->next_tl )
877 tl->timer_list = DETACHED_LIST;
878 }
879#ifdef TM_TIMER_DEBUG
880 check_timer_list( timer_list, "after split" );
881#endif
882
883#ifdef EXTRA_DEBUG
884 if (timer_list->last_tl.prev_tl==0) {
885 LM_CRIT("Oh no, zero link in trailing timer element\n");
886 abort();
887 };
888#endif
889
890 /* give the list lock away */
891 unlock(timer_list->mutex);
892
893 return ret;
894}
895
896
897

Callers 2

timer_routineFunction · 0.85
utimer_routineFunction · 0.85

Calls 1

check_timer_listFunction · 0.85

Tested by

no test coverage detected