mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-14 00:24:05 +00:00
Merge "pjsip_scheduler.c: Add ability to trace scheduled tasks."
This commit is contained in:
@@ -1620,16 +1620,23 @@ enum ast_sip_scheduler_task_flags {
|
|||||||
*/
|
*/
|
||||||
AST_SIP_SCHED_TASK_DATA_FREE = ( 1 << 3 ),
|
AST_SIP_SCHED_TASK_DATA_FREE = ( 1 << 3 ),
|
||||||
|
|
||||||
/*! \brief AST_SIP_SCHED_TASK_PERIODIC
|
/*!
|
||||||
* The task is scheduled at multiples of interval
|
* \brief The task is scheduled at multiples of interval
|
||||||
* \see Interval
|
* \see Interval
|
||||||
*/
|
*/
|
||||||
AST_SIP_SCHED_TASK_PERIODIC = (0 << 4),
|
AST_SIP_SCHED_TASK_PERIODIC = (0 << 4),
|
||||||
/*! \brief AST_SIP_SCHED_TASK_DELAY
|
/*!
|
||||||
* The next invocation of the task is at last finish + interval
|
* \brief The next invocation of the task is at last finish + interval
|
||||||
* \see Interval
|
* \see Interval
|
||||||
*/
|
*/
|
||||||
AST_SIP_SCHED_TASK_DELAY = (1 << 4),
|
AST_SIP_SCHED_TASK_DELAY = (1 << 4),
|
||||||
|
/*!
|
||||||
|
* \brief The scheduled task's events are tracked in the debug log.
|
||||||
|
* \details
|
||||||
|
* Schedule events such as scheduling, running, rescheduling, canceling,
|
||||||
|
* and destroying are logged about the task.
|
||||||
|
*/
|
||||||
|
AST_SIP_SCHED_TASK_TRACK = (1 << 5),
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@@ -86,6 +86,9 @@ static int run_task(void *data)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (schtd->flags & AST_SIP_SCHED_TASK_TRACK) {
|
||||||
|
ast_log(LOG_DEBUG, "Sched %p: Running %s\n", schtd, schtd->name);
|
||||||
|
}
|
||||||
ao2_lock(schtd);
|
ao2_lock(schtd);
|
||||||
schtd->last_start = ast_tvnow();
|
schtd->last_start = ast_tvnow();
|
||||||
schtd->is_running = 1;
|
schtd->is_running = 1;
|
||||||
@@ -137,6 +140,10 @@ static int run_task(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ao2_unlock(schtd);
|
ao2_unlock(schtd);
|
||||||
|
if (schtd->flags & AST_SIP_SCHED_TASK_TRACK) {
|
||||||
|
ast_log(LOG_DEBUG, "Sched %p: Rescheduled %s for %d ms\n", schtd, schtd->name,
|
||||||
|
delay);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -159,6 +166,9 @@ static int push_to_serializer(const void *data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (schtd->flags & AST_SIP_SCHED_TASK_TRACK) {
|
||||||
|
ast_log(LOG_DEBUG, "Sched %p: Ready to run %s\n", schtd, schtd->name);
|
||||||
|
}
|
||||||
ao2_t_ref(schtd, +1, "Give ref to run_task()");
|
ao2_t_ref(schtd, +1, "Give ref to run_task()");
|
||||||
if (ast_sip_push_task(schtd->serializer, run_task, schtd)) {
|
if (ast_sip_push_task(schtd->serializer, run_task, schtd)) {
|
||||||
/*
|
/*
|
||||||
@@ -181,6 +191,10 @@ int ast_sip_sched_task_cancel(struct ast_sip_sched_task *schtd)
|
|||||||
int res;
|
int res;
|
||||||
int sched_id;
|
int sched_id;
|
||||||
|
|
||||||
|
if (schtd->flags & AST_SIP_SCHED_TASK_TRACK) {
|
||||||
|
ast_log(LOG_DEBUG, "Sched %p: Canceling %s\n", schtd, schtd->name);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prevent any tasks in the serializer queue from
|
* Prevent any tasks in the serializer queue from
|
||||||
* running and restarting the scheduled item on us
|
* running and restarting the scheduled item on us
|
||||||
@@ -347,6 +361,9 @@ static void schtd_dtor(void *data)
|
|||||||
{
|
{
|
||||||
struct ast_sip_sched_task *schtd = data;
|
struct ast_sip_sched_task *schtd = data;
|
||||||
|
|
||||||
|
if (schtd->flags & AST_SIP_SCHED_TASK_TRACK) {
|
||||||
|
ast_log(LOG_DEBUG, "Sched %p: Destructor %s\n", schtd, schtd->name);
|
||||||
|
}
|
||||||
if (schtd->flags & AST_SIP_SCHED_TASK_DATA_AO2) {
|
if (schtd->flags & AST_SIP_SCHED_TASK_DATA_AO2) {
|
||||||
/* release our own ref, then release the callers if asked to do so */
|
/* release our own ref, then release the callers if asked to do so */
|
||||||
ao2_ref(schtd->task_data, (schtd->flags & AST_SIP_SCHED_TASK_DATA_FREE) ? -2 : -1);
|
ao2_ref(schtd->task_data, (schtd->flags & AST_SIP_SCHED_TASK_DATA_FREE) ? -2 : -1);
|
||||||
@@ -387,6 +404,10 @@ struct ast_sip_sched_task *ast_sip_schedule_task(struct ast_taskprocessor *seria
|
|||||||
task_id = ast_atomic_fetchadd_int(&task_count, 1);
|
task_id = ast_atomic_fetchadd_int(&task_count, 1);
|
||||||
sprintf(schtd->name, "task_%08x", task_id);
|
sprintf(schtd->name, "task_%08x", task_id);
|
||||||
}
|
}
|
||||||
|
if (schtd->flags & AST_SIP_SCHED_TASK_TRACK) {
|
||||||
|
ast_log(LOG_DEBUG, "Sched %p: Scheduling %s for %d ms\n", schtd, schtd->name,
|
||||||
|
interval);
|
||||||
|
}
|
||||||
schtd->when_queued = ast_tvnow();
|
schtd->when_queued = ast_tvnow();
|
||||||
if (!(schtd->flags & AST_SIP_SCHED_TASK_DELAY)) {
|
if (!(schtd->flags & AST_SIP_SCHED_TASK_DELAY)) {
|
||||||
schtd->next_periodic = ast_tvadd(schtd->when_queued,
|
schtd->next_periodic = ast_tvadd(schtd->when_queued,
|
||||||
|
Reference in New Issue
Block a user