Version 0.2.0 from FTP
git-svn-id: https://origsvn.digium.com/svn/libpri/trunk@13 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
parent
c84465ba47
commit
0aa2e6fe6c
@ -70,6 +70,7 @@ struct pri {
|
||||
|
||||
/* Used by scheduler */
|
||||
struct timeval tv;
|
||||
int schedev;
|
||||
pri_event ev; /* Static event thingy */
|
||||
|
||||
/* Q.921 Re-transmission queue */
|
||||
@ -81,7 +82,7 @@ struct pri {
|
||||
|
||||
extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data);
|
||||
|
||||
extern int pri_schedule_run(struct pri *pri);
|
||||
extern pri_event *pri_schedule_run(struct pri *pri);
|
||||
|
||||
extern void pri_schedule_del(struct pri *pri, int ev);
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#define T_WAIT_MAX 10000
|
||||
#define T_200 1000 /* 1 second between SABME's */
|
||||
#define T_203 10000 /* 10 seconds with no packets max */
|
||||
#define N_200 3 /* 3 retries */
|
||||
|
||||
#define Q921_FRAMETYPE_MASK 0x3
|
||||
|
||||
|
13
prisched.c
13
prisched.c
@ -46,8 +46,10 @@ int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), vo
|
||||
gettimeofday(&tv, NULL);
|
||||
tv.tv_sec += ms / 1000;
|
||||
tv.tv_usec += (ms % 1000) * 1000;
|
||||
if (tv.tv_usec > 1000000)
|
||||
if (tv.tv_usec > 1000000) {
|
||||
tv.tv_usec -= 1000000;
|
||||
tv.tv_sec += 1;
|
||||
}
|
||||
pri->pri_sched[x].when = tv;
|
||||
pri->pri_sched[x].callback = function;
|
||||
pri->pri_sched[x].data = data;
|
||||
@ -68,11 +70,10 @@ struct timeval *pri_schedule_next(struct pri *pri)
|
||||
return closest;
|
||||
}
|
||||
|
||||
int pri_schedule_run(struct pri *pri)
|
||||
pri_event *pri_schedule_run(struct pri *pri)
|
||||
{
|
||||
struct timeval tv;
|
||||
int x;
|
||||
int p = 0;
|
||||
void (*callback)(void *);
|
||||
void *data;
|
||||
gettimeofday(&tv, NULL);
|
||||
@ -81,15 +82,17 @@ int pri_schedule_run(struct pri *pri)
|
||||
((pri->pri_sched[x].when.tv_sec < tv.tv_sec) ||
|
||||
((pri->pri_sched[x].when.tv_sec == tv.tv_sec) &&
|
||||
(pri->pri_sched[x].when.tv_usec <= tv.tv_usec)))) {
|
||||
p++;
|
||||
pri->schedev = 0;
|
||||
callback = pri->pri_sched[x].callback;
|
||||
data = pri->pri_sched[x].data;
|
||||
pri->pri_sched[x].callback = NULL;
|
||||
pri->pri_sched[x].data = NULL;
|
||||
callback(data);
|
||||
if (pri->schedev)
|
||||
return &pri->ev;
|
||||
}
|
||||
}
|
||||
return p;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void pri_schedule_del(struct pri *pri,int id)
|
||||
|
Loading…
Reference in New Issue
Block a user