* 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)
This commit is contained in:
parent
d6cab81175
commit
ff117a8d11
|
@ -39,7 +39,7 @@ typedef int gsm_cbfn(unsigned int hooknum,
|
|||
#define LCHAN_RELEASE_TIMEOUT 4, 0
|
||||
#define use_lchan(lchan) \
|
||||
do { lchan->use_count++; \
|
||||
schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); } while(0);
|
||||
bsc_schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); } while(0);
|
||||
|
||||
#define put_lchan(lchan) \
|
||||
do { lchan->use_count--; } while(0);
|
||||
|
|
|
@ -55,17 +55,17 @@ struct timer_list {
|
|||
/**
|
||||
* timer management
|
||||
*/
|
||||
void add_timer(struct timer_list *timer);
|
||||
void schedule_timer(struct timer_list *timer, int seconds, int microseconds);
|
||||
void del_timer(struct timer_list *timer);
|
||||
int timer_pending(struct timer_list *timer);
|
||||
void bsc_add_timer(struct timer_list *timer);
|
||||
void bsc_schedule_timer(struct timer_list *timer, int seconds, int microseconds);
|
||||
void bsc_del_timer(struct timer_list *timer);
|
||||
int bsc_timer_pending(struct timer_list *timer);
|
||||
|
||||
|
||||
/**
|
||||
* internal timer list management
|
||||
*/
|
||||
struct timeval *nearest_timer();
|
||||
void prepare_timers();
|
||||
void update_timers();
|
||||
struct timeval *bsc_nearest_timer();
|
||||
void bsc_prepare_timers();
|
||||
int bsc_update_timers();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
10
src/paging.c
10
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 */
|
||||
|
|
|
@ -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) {
|
||||
|
|
22
src/timer.c
22
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;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ static void timer_fired(unsigned long data)
|
|||
printf("Fired timer: %lu\n", data);
|
||||
|
||||
if (data == 1) {
|
||||
schedule_timer(&timer_one, 3, 0);
|
||||
del_timer(&timer_two);
|
||||
bsc_schedule_timer(&timer_one, 3, 0);
|
||||
bsc_del_timer(&timer_two);
|
||||
} else if (data == 2) {
|
||||
printf("Should not be fired... bug in del_timer\n");
|
||||
} else if (data == 3) {
|
||||
|
@ -60,9 +60,9 @@ int main(int argc, char** argv)
|
|||
{
|
||||
printf("Starting... timer\n");
|
||||
|
||||
schedule_timer(&timer_one, 3, 0);
|
||||
schedule_timer(&timer_two, 5, 0);
|
||||
schedule_timer(&timer_three, 4, 0);
|
||||
bsc_schedule_timer(&timer_one, 3, 0);
|
||||
bsc_schedule_timer(&timer_two, 5, 0);
|
||||
bsc_schedule_timer(&timer_three, 4, 0);
|
||||
|
||||
while (1) {
|
||||
bsc_select_main();
|
||||
|
|
Loading…
Reference in New Issue