diff options
author | Harald Welte <laforge@gnumonks.org> | 2009-05-23 05:22:08 +0000 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2009-05-23 05:22:08 +0000 |
commit | ff117a8d1138d9629df543ed00e698ee3a0bdb73 (patch) | |
tree | 6e27b6ebaa4229d8cea5adb8ab8025f96cd3229c /src | |
parent | d6cab81175ec6afe5708ade7557d35330c0cb973 (diff) |
* rename the timer functions to avoid name collisions with libmisdn.
* the return value of bsc_update_timers() is required for applications to find out if a timer was fired
(Andreas Eversberg)
Diffstat (limited to 'src')
-rw-r--r-- | src/bs11_config.c | 2 | ||||
-rw-r--r-- | src/chan_alloc.c | 6 | ||||
-rw-r--r-- | src/gsm_04_08.c | 4 | ||||
-rw-r--r-- | src/ipaccess-find.c | 4 | ||||
-rw-r--r-- | src/paging.c | 10 | ||||
-rw-r--r-- | src/select.c | 6 | ||||
-rw-r--r-- | src/timer.c | 22 |
7 files changed, 29 insertions, 25 deletions
diff --git a/src/bs11_config.c b/src/bs11_config.c index 25ff0e0e6..3da0c528d 100644 --- a/src/bs11_config.c +++ b/src/bs11_config.c @@ -633,7 +633,7 @@ int handle_serial_msg(struct msgb *rx_msg) abis_nm_bs11_factory_logon(g_bts, 1); break; case STATE_LOGON_ACK: - schedule_timer(&status_timer, 5, 0); + bsc_schedule_timer(&status_timer, 5, 0); break; default: break; diff --git a/src/chan_alloc.c b/src/chan_alloc.c index 7edde6e1f..fa07273fa 100644 --- a/src/chan_alloc.c +++ b/src/chan_alloc.c @@ -178,7 +178,7 @@ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type) /* Configure the time and start it so it will be closed */ lchan->release_timer.cb = auto_release_channel; lchan->release_timer.data = lchan; - schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); + bsc_schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); } return lchan; @@ -199,7 +199,7 @@ void lchan_free(struct gsm_lchan *lchan) } /* stop the timer */ - del_timer(&lchan->release_timer); + bsc_del_timer(&lchan->release_timer); /* FIXME: ts_free() the timeslot, if we're the last logical * channel using it */ @@ -233,7 +233,7 @@ static void auto_release_channel(void *_lchan) struct gsm_lchan *lchan = _lchan; if (!lchan_auto_release(lchan)) - schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); + bsc_schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); } struct gsm_lchan* lchan_find(struct gsm_bts *bts, struct gsm_subscriber *subscr) { diff --git a/src/gsm_04_08.c b/src/gsm_04_08.c index fe1637e9a..e178d99c9 100644 --- a/src/gsm_04_08.c +++ b/src/gsm_04_08.c @@ -165,7 +165,7 @@ static void release_loc_updating_req(struct gsm_lchan *lchan) if (!lchan->loc_operation) return; - del_timer(&lchan->loc_operation->updating_timer); + bsc_del_timer(&lchan->loc_operation->updating_timer); free(lchan->loc_operation); lchan->loc_operation = 0; put_lchan(lchan); @@ -527,7 +527,7 @@ static void schedule_reject(struct gsm_lchan *lchan) { lchan->loc_operation->updating_timer.cb = loc_upd_rej_cb; lchan->loc_operation->updating_timer.data = lchan; - schedule_timer(&lchan->loc_operation->updating_timer, 5, 0); + bsc_schedule_timer(&lchan->loc_operation->updating_timer, 5, 0); } static const char *lupd_name(u_int8_t type) diff --git a/src/ipaccess-find.c b/src/ipaccess-find.c index bada3b259..32f42e904 100644 --- a/src/ipaccess-find.c +++ b/src/ipaccess-find.c @@ -143,7 +143,7 @@ static void timer_cb(void *_data) bfd->when |= BSC_FD_WRITE; - schedule_timer(&timer, 5, 0); + bsc_schedule_timer(&timer, 5, 0); } int main(int argc, char **argv) @@ -165,7 +165,7 @@ int main(int argc, char **argv) timer.cb = timer_cb; timer.data = &bfd; - schedule_timer(&timer, 5, 0); + bsc_schedule_timer(&timer, 5, 0); printf("Trying to find ip.access BTS by broadcast UDP...\n"); diff --git a/src/paging.c b/src/paging.c index 4de93c6c8..d777d6642 100644 --- a/src/paging.c +++ b/src/paging.c @@ -78,7 +78,7 @@ static void paging_remove_request(struct gsm_bts_paging_state *paging_bts, paging_bts->last_request = NULL; } - del_timer(&to_be_deleted->T3113); + bsc_del_timer(&to_be_deleted->T3113); llist_del(&to_be_deleted->entry); subscr_put(to_be_deleted->subscr); free(to_be_deleted); @@ -158,7 +158,7 @@ static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_b } while (paging_bts->available_slots > 0 && initial_request != current_request); - schedule_timer(&paging_bts->work_timer, 1, 0); + bsc_schedule_timer(&paging_bts->work_timer, 1, 0); } static void paging_worker(void *data) @@ -230,11 +230,11 @@ void paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr, req->cbfn_param = data; req->T3113.cb = paging_T3113_expired; req->T3113.data = req; - schedule_timer(&req->T3113, T3113_VALUE); + bsc_schedule_timer(&req->T3113, T3113_VALUE); llist_add_tail(&req->entry, &bts_entry->pending_requests); - if (!timer_pending(&bts_entry->work_timer)) - schedule_timer(&bts_entry->work_timer, 1, 0); + if (!bsc_timer_pending(&bts_entry->work_timer)) + bsc_schedule_timer(&bts_entry->work_timer, 1, 0); } /* we consciously ignore the type of the request here */ diff --git a/src/select.c b/src/select.c index 925f3395f..157e23500 100644 --- a/src/select.c +++ b/src/select.c @@ -75,13 +75,13 @@ int bsc_select_main() FD_SET(ufd->fd, &exceptset); } - prepare_timers(); - i = select(maxfd+1, &readset, &writeset, &exceptset, nearest_timer()); + bsc_prepare_timers(); + i = select(maxfd+1, &readset, &writeset, &exceptset, bsc_nearest_timer()); if (i < 0) return i; /* fire timers */ - update_timers(); + bsc_update_timers(); /* call registered callback functions */ llist_for_each_entry_safe(ufd, tmp, &bsc_fds, list) { diff --git a/src/timer.c b/src/timer.c index 3ec085bdf..a942ffd6d 100644 --- a/src/timer.c +++ b/src/timer.c @@ -31,7 +31,7 @@ static struct timeval s_select_time; #define TIME_SMALLER(left, right) \ (left.tv_sec*MICRO_SECONDS+left.tv_usec) <= (right.tv_sec*MICRO_SECONDS+right.tv_usec) -void add_timer(struct timer_list *timer) +void bsc_add_timer(struct timer_list *timer) { struct timer_list *list_timer; @@ -47,7 +47,7 @@ void add_timer(struct timer_list *timer) llist_add(&timer->entry, &timer_list); } -void schedule_timer(struct timer_list *timer, int seconds, int microseconds) +void bsc_schedule_timer(struct timer_list *timer, int seconds, int microseconds) { struct timeval current_time; @@ -56,10 +56,10 @@ void schedule_timer(struct timer_list *timer, int seconds, int microseconds) currentTime += seconds * MICRO_SECONDS + microseconds; timer->timeout.tv_sec = currentTime / MICRO_SECONDS; timer->timeout.tv_usec = currentTime % MICRO_SECONDS; - add_timer(timer); + bsc_add_timer(timer); } -void del_timer(struct timer_list *timer) +void bsc_del_timer(struct timer_list *timer) { if (timer->in_list) { timer->active = 0; @@ -68,7 +68,7 @@ void del_timer(struct timer_list *timer) } } -int timer_pending(struct timer_list *timer) +int bsc_timer_pending(struct timer_list *timer) { return timer->active; } @@ -79,7 +79,7 @@ int timer_pending(struct timer_list *timer) * If the nearest timer timed out return NULL and then we will * dispatch everything after the select */ -struct timeval *nearest_timer() +struct timeval *bsc_nearest_timer() { struct timeval current_time; @@ -106,7 +106,7 @@ struct timeval *nearest_timer() /* * Find the nearest time and update s_nearest_time */ -void prepare_timers() +void bsc_prepare_timers() { struct timer_list *timer, *nearest_timer = NULL; llist_for_each_entry(timer, &timer_list, entry) { @@ -125,10 +125,11 @@ void prepare_timers() /* * fire all timers... and remove them */ -void update_timers() +int bsc_update_timers() { struct timeval current_time; struct timer_list *timer, *tmp; + int work = 0; gettimeofday(¤t_time, NULL); @@ -157,6 +158,7 @@ restart: timer->handled = 1; timer->active = 0; (*timer->cb)(timer->data); + work = 1; goto restart; } } @@ -164,7 +166,9 @@ restart: llist_for_each_entry_safe(timer, tmp, &timer_list, entry) { timer->handled = 0; if (!timer->active) { - del_timer(timer); + bsc_del_timer(timer); } } + + return work; } |