aboutsummaryrefslogtreecommitdiffstats
path: root/sched.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-08-22 22:55:06 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-08-22 22:55:06 +0000
commit9f55bb92598bacb7b38cd30631dbb177a8e6e8c8 (patch)
tree59c342fa106f478400e490e62a78ec9d7358a283 /sched.c
parent77ffeda4e8944e678e51dae03cf0b986c31817f8 (diff)
add preliminary support for SIP timers (issue #4359)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6362 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'sched.c')
-rwxr-xr-xsched.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sched.c b/sched.c
index 84406f607..a3d6c7268 100755
--- a/sched.c
+++ b/sched.c
@@ -42,6 +42,7 @@ struct sched {
int id; /* ID number of event */
struct timeval when; /* Absolute time event should take place */
int resched; /* When to reschedule */
+ int variable; /* Use return value from callback to reschedule */
void *data; /* Data */
ast_sched_cb callback; /* Callback */
};
@@ -209,7 +210,8 @@ static int sched_settime(struct timeval *tv, int when)
return 0;
}
-int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, void *data)
+
+int ast_sched_add_variable(struct sched_context *con, int when, ast_sched_cb callback, void *data, int variable)
{
/*
* Schedule callback(data) to happen when ms into the future
@@ -227,6 +229,7 @@ int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, vo
tmp->callback = callback;
tmp->data = data;
tmp->resched = when;
+ tmp->variable = variable;
tmp->when = ast_tv(0, 0);
if (sched_settime(&tmp->when, when)) {
sched_release(con, tmp);
@@ -243,6 +246,11 @@ int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, vo
return res;
}
+int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, void *data)
+{
+ return ast_sched_add_variable(con, when, callback, data, 0);
+}
+
int ast_sched_del(struct sched_context *con, int id)
{
/*
@@ -359,7 +367,7 @@ int ast_sched_runq(struct sched_context *con)
* If they return non-zero, we should schedule them to be
* run again.
*/
- if (sched_settime(&current->when, current->resched)) {
+ if (sched_settime(&current->when, current->variable? res : current->resched)) {
sched_release(con, current);
} else
schedule(con, current);