pjsip_scheduler.c: Add type ONESHOT and enhance cli show command

* Added a ONESHOT type that never reschedules.

* Added "like" capability to "pjsip show scheduled_tasks" so you can do
  the following:

  CLI> pjsip show scheduled_tasks like outreg
  PJSIP Scheduled Tasks:

  Task Name                                     Interval  Times Run ...
  ============================================= ========= ========= ...
  pjsip/outreg/testtrunk-reg-0-00000074            50.000   oneshot ...
  pjsip/outreg/voipms-reg-0-00000073              110.000   oneshot ...

* Fixed incorrect display of "Next Start".

* Compacted the displays of times in the CLI.

* Added two new functions (ast_sip_sched_task_get_times2,
  ast_sip_sched_task_get_times_by_name2) that retrieve the interval,
  next start time, and next run time in addition to the times already
  returned by ast_sip_sched_task_get_times().

Change-Id: Ie718ca9fd30490b8a167bedf6b0b06d619dc52f3
This commit is contained in:
George Joseph
2020-11-02 12:53:58 -07:00
committed by Kevin Harwell
parent da0f2ea99e
commit 569fc28966
2 changed files with 167 additions and 59 deletions

View File

@@ -1784,6 +1784,12 @@ enum ast_sip_scheduler_task_flags {
*/
AST_SIP_SCHED_TASK_VARIABLE = (1 << 0),
/*!
* Run just once.
* Return values are ignored.
*/
AST_SIP_SCHED_TASK_ONESHOT = (1 << 6),
/*!
* The task data is not an AO2 object.
*/
@@ -1905,6 +1911,26 @@ int ast_sip_sched_task_cancel_by_name(const char *name);
int ast_sip_sched_task_get_times(struct ast_sip_sched_task *schtd,
struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end);
/*!
* \brief Gets the queued, last start, last_end, time left, interval, next run
* \since 16.15.0
* \since 18.1.0
*
* \param schtd The task structure pointer
* \param[out] when_queued Pointer to a timeval structure to contain the time when queued
* \param[out] last_start Pointer to a timeval structure to contain the time when last started
* \param[out] last_end Pointer to a timeval structure to contain the time when last ended
* \param[out] interval Pointer to an int to contain the interval in ms
* \param[out] time_left Pointer to an int to contain the ms left to the next run
* \param[out] last_end Pointer to a timeval structure to contain the next run time
* \retval 0 Success
* \retval -1 Failure
* \note Any of the pointers can be NULL if you don't need them.
*/
int ast_sip_sched_task_get_times2(struct ast_sip_sched_task *schtd,
struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end,
int *interval, int *time_left, struct timeval *next_start);
/*!
* \brief Gets the last start and end times of the task by name
* \since 13.9.0
@@ -1920,6 +1946,26 @@ int ast_sip_sched_task_get_times(struct ast_sip_sched_task *schtd,
int ast_sip_sched_task_get_times_by_name(const char *name,
struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end);
/*!
* \brief Gets the queued, last start, last_end, time left, interval, next run by task name
* \since 16.15.0
* \since 18.1.0
*
* \param name The task name
* \param[out] when_queued Pointer to a timeval structure to contain the time when queued
* \param[out] last_start Pointer to a timeval structure to contain the time when last started
* \param[out] last_end Pointer to a timeval structure to contain the time when last ended
* \param[out] interval Pointer to an int to contain the interval in ms
* \param[out] time_left Pointer to an int to contain the ms left to the next run
* \param[out] last_end Pointer to a timeval structure to contain the next run time
* \retval 0 Success
* \retval -1 Failure
* \note Any of the pointers can be NULL if you don't need them.
*/
int ast_sip_sched_task_get_times_by_name2(const char *name,
struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end,
int *interval, int *time_left, struct timeval *next_start);
/*!
* \brief Gets the number of milliseconds until the next invocation
* \since 13.9.0