Asterisk - The Open Source Telephony Project
18.5.0
|
Typedefs | |
typedef int(* | ast_sip_task) (void *user_data) |
Enumerations | |
enum | ast_sip_scheduler_task_flags { AST_SIP_SCHED_TASK_DEFAULTS = (0 << 0), AST_SIP_SCHED_TASK_FIXED = (0 << 0), AST_SIP_SCHED_TASK_VARIABLE = (1 << 0), AST_SIP_SCHED_TASK_ONESHOT = (1 << 6), AST_SIP_SCHED_TASK_DATA_NOT_AO2 = (0 << 1), AST_SIP_SCHED_TASK_DATA_AO2 = (1 << 1), AST_SIP_SCHED_TASK_DATA_NO_CLEANUP = (0 << 3), AST_SIP_SCHED_TASK_DATA_FREE = ( 1 << 3 ), AST_SIP_SCHED_TASK_PERIODIC = (0 << 4), AST_SIP_SCHED_TASK_DELAY = (1 << 4), AST_SIP_SCHED_TASK_TRACK = (1 << 5) } |
Task flags for the res_pjsip scheduler. More... | |
Functions | |
struct ast_taskprocessor * | ast_sip_create_serializer (const char *name) |
Create a new serializer for SIP tasks. More... | |
struct ast_taskprocessor * | ast_sip_create_serializer_group (const char *name, struct ast_serializer_shutdown_group *shutdown_group) |
Create a new serializer for SIP tasks. More... | |
struct ast_sip_endpoint * | ast_sip_dialog_get_endpoint (pjsip_dialog *dlg) |
Get the endpoint associated with this dialog. More... | |
void | ast_sip_dialog_set_endpoint (pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint) |
Set an endpoint on a SIP dialog so in-dialog requests do not undergo endpoint lookup. More... | |
void | ast_sip_dialog_set_serializer (pjsip_dialog *dlg, struct ast_taskprocessor *serializer) |
Set a serializer on a SIP dialog so requests and responses are automatically serialized. More... | |
struct ast_taskprocessor * | ast_sip_get_distributor_serializer (pjsip_rx_data *rdata) |
Determine the distributor serializer for the SIP message. More... | |
int | ast_sip_push_task (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data) |
Pushes a task to SIP servants. More... | |
int | ast_sip_push_task_synchronous (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data) |
Push a task to SIP servants and wait for it to complete. More... | |
int | ast_sip_push_task_wait_serializer (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data) |
Push a task to the serializer and wait for it to complete. More... | |
int | ast_sip_push_task_wait_servant (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data) |
Push a task to SIP servants and wait for it to complete. More... | |
int | ast_sip_sched_is_task_running (struct ast_sip_sched_task *schtd) |
Checks if the task is currently running. More... | |
int | ast_sip_sched_is_task_running_by_name (const char *name) |
Checks if the task is currently running. More... | |
int | ast_sip_sched_task_cancel (struct ast_sip_sched_task *schtd) |
Cancels the next invocation of a task. More... | |
int | ast_sip_sched_task_cancel_by_name (const char *name) |
Cancels the next invocation of a task by name. More... | |
int | ast_sip_sched_task_get_name (struct ast_sip_sched_task *schtd, char *name, size_t maxlen) |
Gets the task name. More... | |
int | ast_sip_sched_task_get_next_run (struct ast_sip_sched_task *schtd) |
Gets the number of milliseconds until the next invocation. More... | |
int | ast_sip_sched_task_get_next_run_by_name (const char *name) |
Gets the number of milliseconds until the next invocation. More... | |
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) |
Gets the last start and end times of the task. More... | |
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) |
Gets the queued, last start, last_end, time left, interval, next run. More... | |
int | ast_sip_sched_task_get_times_by_name (const char *name, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end) |
Gets the last start and end times of the task by name. More... | |
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) |
Gets the queued, last start, last_end, time left, interval, next run by task name. More... | |
struct ast_sip_sched_task * | ast_sip_schedule_task (struct ast_taskprocessor *serializer, int interval, ast_sip_task sip_task, const char *name, void *task_data, enum ast_sip_scheduler_task_flags flags) |
Schedule a task to run in the res_pjsip thread pool. More... | |
int | ast_sip_thread_is_servant (void) |
Determine if the current thread is a SIP servant thread. More... | |
Asterisk threads are those that originate from outside of SIP but within Asterisk. The most common of these threads are PBX (channel) threads and the autoservice thread. Most interaction with these threads will be through channel technology callbacks. Within these threads, it is fine to handle Asterisk data from outside of SIP, but any handling of SIP data should be left to servants, especially if you wish to call into PJSIP for anything. Asterisk threads are not registered with PJLIB, so attempting to call into PJSIP will cause an assertion to be triggered, thus causing the program to crash.
PJSIP threads are those that originate from handling of PJSIP events, such as an incoming SIP request or response, or a transaction timeout. The role of these threads is to process information as quickly as possible so that the next item on the SIP socket(s) can be serviced. On incoming messages, Asterisk automatically will push the request to a servant thread. When your module callback is called, processing will already be in a servant. However, for other PJSIP events, such as transaction state changes due to timer expirations, your module will be called into from a PJSIP thread. If you are called into from a PJSIP thread, then you should push whatever processing is needed to a servant as soon as possible. You can discern if you are currently in a SIP servant thread using the ast_sip_thread_is_servant function.
Servants are where the bulk of SIP work should be performed. These threads exist in order to do the work that Asterisk threads and PJSIP threads hand off to them. Servant threads register themselves with PJLIB, meaning that they are capable of calling PJSIP and PJLIB functions if they wish.
Tasks are handed off to servant threads using the API call ast_sip_push_task. The first parameter of this call is a serializer. If this pointer is NULL, then the work will be handed off to whatever servant can currently handle the task. If this pointer is non-NULL, then the task will not be executed until previous tasks pushed with the same serializer have completed. For more information on serializers and the benefits they provide, see ast_threadpool_serializer
Some situations require that a task run periodically or at a future time. Normally the ast_sched functionality would be used but ast_sched only uses 1 thread for all tasks and that thread isn't registered with PJLIB and therefore can't do any PJSIP related work.ast_sip_sched uses ast_sched only as a scheduled queue. When a task is ready to run, it's pushed to a Serializer to be invoked asynchronously by a Servant. This ensures that the task is executed in a PJLIB registered thread and allows the ast_sched thread to immediately continue processing the queue. The Serializer used by ast_sip_sched is one of your choosing or a random one from the res_pjsip pool if you don't choose one.
Do not make assumptions about individual threads based on a corresponding serializer. In other words, just because several tasks use the same serializer when being pushed to servants, it does not mean that the same thread is necessarily going to execute those tasks, even though they are all guaranteed to be executed in sequence.
typedef int(* ast_sip_task) (void *user_data) |
Definition at line 1573 of file res_pjsip.h.
Task flags for the res_pjsip scheduler.
The default is AST_SIP_SCHED_TASK_FIXED | AST_SIP_SCHED_TASK_DATA_NOT_AO2 | AST_SIP_SCHED_TASK_DATA_NO_CLEANUP | AST_SIP_SCHED_TASK_PERIODIC
Definition at line 1767 of file res_pjsip.h.
struct ast_taskprocessor* ast_sip_create_serializer | ( | const char * | name | ) |
Create a new serializer for SIP tasks.
See ast_threadpool_serializer for more information on serializers. SIP creates serializers so that tasks operating on similar data will run in sequence.
name | Name of the serializer. (must be unique) |
NULL | Failure |
non-NULL | Newly-created serializer |
Definition at line 5133 of file res_pjsip.c.
References ast_sip_create_serializer_group(), and NULL.
Referenced by allocate_subscription_tree(), ast_res_pjsip_init_options_handling(), ast_sip_session_alloc(), create_websocket_serializer(), distributor_pool_setup(), load_module(), refer_progress_alloc(), and scheduler().
struct ast_taskprocessor* ast_sip_create_serializer_group | ( | const char * | name, |
struct ast_serializer_shutdown_group * | shutdown_group | ||
) |
Create a new serializer for SIP tasks.
See ast_threadpool_serializer for more information on serializers. SIP creates serializers so that tasks operating on similar data will run in sequence.
name | Name of the serializer. (must be unique) |
shutdown_group | Group shutdown controller. (NULL if no group association) |
NULL | Failure |
non-NULL | Newly-created serializer |
Definition at line 5128 of file res_pjsip.c.
References ast_threadpool_serializer_group().
Referenced by ast_sip_create_serializer(), sip_options_aor_alloc(), sip_outbound_publisher_alloc(), and sip_outbound_registration_state_alloc().
struct ast_sip_endpoint* ast_sip_dialog_get_endpoint | ( | pjsip_dialog * | dlg | ) |
Get the endpoint associated with this dialog.
This function increases the refcount of the endpoint by one. Release the reference once you are finished with the endpoint.
dlg | The SIP dialog from which to retrieve the endpoint |
NULL | No endpoint associated with this dialog |
non-NULL | The endpoint. |
Definition at line 322 of file pjsip_distributor.c.
References ao2_bump, ao2_find, ao2_lock, ao2_ref, ao2_unlock, distributor_dialog_data::endpoint, NULL, and OBJ_SEARCH_KEY.
Referenced by digest_create_request_with_auth().
void ast_sip_dialog_set_endpoint | ( | pjsip_dialog * | dlg, |
struct ast_sip_endpoint * | endpoint | ||
) |
Set an endpoint on a SIP dialog so in-dialog requests do not undergo endpoint lookup.
dlg | The SIP dialog itself |
endpoint | The endpoint that this dialog is communicating with |
Definition at line 294 of file pjsip_distributor.c.
References ao2_alloc, ao2_find, ao2_link_flags, ao2_lock, ao2_ref, ao2_unlink_flags, ao2_unlock, ao2_wrlock, distributor_dialog_data::dlg, distributor_dialog_data::endpoint, NULL, OBJ_NOLOCK, OBJ_SEARCH_KEY, and distributor_dialog_data::serializer.
Referenced by ast_sip_session_alloc(), pubsub_on_evsub_state(), session_end_completion(), and subscription_setup_dialog().
void ast_sip_dialog_set_serializer | ( | pjsip_dialog * | dlg, |
struct ast_taskprocessor * | serializer | ||
) |
Set a serializer on a SIP dialog so requests and responses are automatically serialized.
Passing a NULL serializer is a way to remove a serializer from a dialog.
dlg | The SIP dialog itself |
serializer | The serializer to use |
Definition at line 266 of file pjsip_distributor.c.
References ao2_alloc, ao2_find, ao2_link_flags, ao2_lock, ao2_ref, ao2_unlink_flags, ao2_unlock, ao2_wrlock, distributor_dialog_data::dlg, distributor_dialog_data::endpoint, NULL, OBJ_NOLOCK, OBJ_SEARCH_KEY, and distributor_dialog_data::serializer.
Referenced by ast_sip_session_alloc(), pubsub_on_evsub_state(), session_end_completion(), and subscription_setup_dialog().
struct ast_taskprocessor* ast_sip_get_distributor_serializer | ( | pjsip_rx_data * | rdata | ) |
Determine the distributor serializer for the SIP message.
rdata | The incoming message. |
Calculated | distributor serializer on success. |
NULL | on error. |
Definition at line 448 of file pjsip_distributor.c.
References ao2_bump, ARRAY_LEN, ast_debug, ast_str_hash_restrict(), ast_taskprocessor_name(), endpoint_lookup(), NULL, pjstr_hash(), and pjstr_hash_add().
Referenced by allocate_subscription_tree(), ast_sip_session_alloc(), distributor(), and subscription_persistence_recreate().
int ast_sip_push_task | ( | struct ast_taskprocessor * | serializer, |
int(*)(void *) | sip_task, | ||
void * | task_data | ||
) |
Pushes a task to SIP servants.
This uses the serializer provided to determine how to push the task. If the serializer is NULL, then the task will be pushed to the servants directly. If the serializer is non-NULL, then the task will be queued behind other tasks associated with the same serializer.
serializer | The serializer to which the task belongs. Can be NULL |
sip_task | The task to execute |
task_data | The parameter to pass to the task when it executes |
0 | Success |
-1 | Failure |
Definition at line 5138 of file res_pjsip.c.
References ast_serializer_pool_get(), ast_taskprocessor_push(), cond, and lock.
Referenced by ast_sip_push_task_wait(), ast_sip_session_suspend(), auth_observer(), cancel_and_unpublish(), chan_pjsip_call(), chan_pjsip_digit_end(), chan_pjsip_hangup(), chan_pjsip_indicate(), chan_pjsip_sendtext_data(), chan_pjsip_set_rtp_peer(), chan_pjsip_transfer(), check_delayed_requests(), contact_observer_updated(), distributor(), exten_state_publisher_state_cb(), handle_topology_request_change(), load_module(), mwi_startup_event_cb(), mwi_stasis_cb(), pjsip_set_history(), pjsip_show_history(), publish_expire(), publisher_client_send(), pubsub_on_client_refresh(), pubsub_on_rx_refresh(), pubsub_on_rx_subscribe_request(), pubsub_on_server_timeout(), push_notify(), push_notify_channel(), push_notify_uri(), push_to_serializer(), qualify_contact_cb(), queue_register(), queue_unregister(), refer_attended_task(), refer_blind_callback(), refer_incoming_attended_request(), refer_incoming_refer_request(), refer_progress_bridge(), refer_progress_destroy(), refer_progress_framehook(), refer_progress_framehook_destroy(), register_contact_transport_shutdown_cb(), registration_transport_shutdown_cb(), resend_reinvite(), sched_cb(), send_contact_notify(), send_notify(), session_end_if_disconnected(), session_inv_on_state_changed(), session_termination_cb(), sip_options_contact_status_update(), sip_outbound_publish_callback(), sip_outbound_publish_client_add_publisher(), sip_outbound_registration_apply(), sip_outbound_registration_response_cb(), sip_outbound_registration_state_destroy(), sip_outbound_registration_timer_cb(), sip_publisher_service_queue(), sip_resolve_callback(), state_changed(), sub_persistence_recreate(), sub_tree_transport_cb(), subscription_persistence_event_cb(), t38_automatic_reject_timer_cb(), and t38_framehook().
int ast_sip_push_task_synchronous | ( | struct ast_taskprocessor * | serializer, |
int(*)(void *) | sip_task, | ||
void * | task_data | ||
) |
Push a task to SIP servants and wait for it to complete.
Definition at line 5213 of file res_pjsip.c.
References ast_sip_push_task_wait_servant().
int ast_sip_push_task_wait_serializer | ( | struct ast_taskprocessor * | serializer, |
int(*)(void *) | sip_task, | ||
void * | task_data | ||
) |
Push a task to the serializer and wait for it to complete.
Like ast_sip_push_task except that it blocks until the task is completed by the specified serializer. If the specified serializer is the current thread then the task executes immediately.
serializer | The SIP serializer to execute the task. NULL if any of the default serializers can be used. |
sip_task | The task to execute |
task_data | The parameter to pass to the task when it executes |
-1 | Failure to push the task. |
Definition at line 5218 of file res_pjsip.c.
References ast_serializer_pool_get(), ast_sip_push_task_wait(), and ast_taskprocessor_is_task().
Referenced by ami_sip_qualify(), aor_observer_deleted(), aor_observer_modified(), ast_res_pjsip_cleanup_options_handling(), ast_res_pjsip_init_options_handling(), chan_pjsip_answer(), cli_qualify(), cli_reload_qualify_aor(), cli_reload_qualify_endpoint(), contact_observer_created(), contact_observer_deleted(), contact_observer_updated(), endpoint_observer_deleted(), endpoint_observer_modified(), func_read_header(), func_write_header(), pjsip_acf_channel_read(), pjsip_acf_dtmf_mode_write(), pjsip_acf_media_offer_write(), pjsip_acf_parse_uri_read(), pjsip_acf_session_refresh_write(), refer_incoming_invite_request(), sip_msg_send(), sip_options_aor_observer_deleted_task(), sip_options_aor_observer_modified_task(), sip_options_cleanup_task(), sip_options_contact_add_management_task(), sip_options_contact_delete_management_task(), sip_options_endpoint_unlink_aor_feeders(), sip_options_synchronize(), sip_options_synchronize_aor(), sip_options_synchronize_endpoint(), sip_options_unused_aor(), sip_outbound_registration_apply(), subscription_persistence_recreate(), and websocket_cb().
int ast_sip_push_task_wait_servant | ( | struct ast_taskprocessor * | serializer, |
int(*)(void *) | sip_task, | ||
void * | task_data | ||
) |
Push a task to SIP servants and wait for it to complete.
Like ast_sip_push_task except that it blocks until the task completes. If the current thread is a SIP servant thread then the task executes immediately. Otherwise, the specified serializer executes the task and the current thread waits for it to complete.
serializer | The SIP serializer to execute the task if the current thread is not a SIP servant. NULL if any of the default serializers can be used. |
sip_task | The task to execute |
task_data | The parameter to pass to the task when it executes |
-1 | Failure to push the task. |
Definition at line 5204 of file res_pjsip.c.
References ast_sip_push_task_wait(), and ast_sip_thread_is_servant().
Referenced by ami_outbound_registration_detail(), ast_sip_initialize_dns(), ast_sip_initialize_resolver(), ast_sip_push_task_synchronous(), ast_sip_register_service(), ast_sip_unregister_service(), chan_pjsip_request_with_stream_topology(), cli_dump_endpt(), current_state_reusable(), reload_module(), sip_outbound_publisher_alloc(), sip_transport_state_destroy(), subscription_tree_destructor(), and unload_module().
int ast_sip_sched_is_task_running | ( | struct ast_sip_sched_task * | schtd | ) |
Checks if the task is currently running.
schtd | The task structure pointer |
0 | not running |
1 | running |
Definition at line 375 of file pjsip_scheduler.c.
References ast_sip_sched_task::is_running.
Referenced by AST_TEST_DEFINE().
int ast_sip_sched_is_task_running_by_name | ( | const char * | name | ) |
Checks if the task is currently running.
name | The task name |
0 | not running or not found |
1 | running |
Definition at line 380 of file pjsip_scheduler.c.
References ao2_find, ao2_ref, ast_strlen_zero, ast_sip_sched_task::is_running, and OBJ_SEARCH_KEY.
Referenced by AST_TEST_DEFINE().
int ast_sip_sched_task_cancel | ( | struct ast_sip_sched_task * | schtd | ) |
Cancels the next invocation of a task.
schtd | The task structure pointer |
0 | Success |
-1 | Failure |
Definition at line 191 of file pjsip_scheduler.c.
References ao2_lock, ao2_unlink, ao2_unlock, ast_log, ast_sched_del(), AST_SIP_SCHED_TASK_TRACK, ast_sip_sched_task::current_scheduler_id, ast_sip_sched_task::flags, ast_sip_sched_task::interval, LOG_DEBUG, and ast_sip_sched_task::name.
Referenced by ast_sip_destroy_scheduler(), ast_sip_sched_task_cancel_by_name(), AST_TEST_DEFINE(), pubsub_on_evsub_state(), pubsub_on_rx_refresh(), scheduler(), sip_options_aor_remove_task(), sip_options_apply_aor_configuration(), sip_options_cleanup_aor_task(), sip_options_contact_add_task(), and sip_options_contact_delete_task().
int ast_sip_sched_task_cancel_by_name | ( | const char * | name | ) |
Cancels the next invocation of a task by name.
name | The task name |
0 | Success |
-1 | Failure |
Definition at line 218 of file pjsip_scheduler.c.
References ao2_find, ao2_ref, ast_sip_sched_task_cancel(), ast_strlen_zero, and OBJ_SEARCH_KEY.
Referenced by AST_TEST_DEFINE().
int ast_sip_sched_task_get_name | ( | struct ast_sip_sched_task * | schtd, |
char * | name, | ||
size_t | maxlen | ||
) |
Gets the task name.
schtd | The task structure pointer |
0 | success |
1 | failure |
Definition at line 334 of file pjsip_scheduler.c.
References ao2_lock, ao2_unlock, ast_copy_string(), and ast_sip_sched_task::name.
Referenced by pubsub_on_evsub_state(), and pubsub_on_rx_refresh().
int ast_sip_sched_task_get_next_run | ( | struct ast_sip_sched_task * | schtd | ) |
Gets the number of milliseconds until the next invocation.
schtd | The task structure pointer |
Definition at line 347 of file pjsip_scheduler.c.
References ast_sip_sched_task_get_times2(), and NULL.
Referenced by ast_sip_sched_task_get_next_run_by_name(), AST_TEST_DEFINE(), and cli_show_tasks().
int ast_sip_sched_task_get_next_run_by_name | ( | const char * | name | ) |
Gets the number of milliseconds until the next invocation.
name | The task name |
Definition at line 356 of file pjsip_scheduler.c.
References ao2_find, ao2_ref, ast_sip_sched_task_get_next_run(), ast_strlen_zero, and OBJ_SEARCH_KEY.
Referenced by AST_TEST_DEFINE().
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 | ||
) |
Gets the last start and end times of the task.
schtd | The task structure pointer | |
[out] | when_queued | Pointer to a timeval structure to contain the time when queued |
[out] | last_start | Pointer to a timeval structure to contain the time when last started |
[out] | last_end | Pointer to a timeval structure to contain the time when last ended |
0 | Success |
-1 | Failure |
Definition at line 299 of file pjsip_scheduler.c.
References ast_sip_sched_task_get_times2(), and NULL.
Referenced by scheduler().
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 | ||
) |
Gets the queued, last start, last_end, time left, interval, next run.
schtd | The task structure pointer | |
[out] | when_queued | Pointer to a timeval structure to contain the time when queued |
[out] | last_start | Pointer to a timeval structure to contain the time when last started |
[out] | last_end | Pointer to a timeval structure to contain the time when last ended |
[out] | interval | Pointer to an int to contain the interval in ms |
[out] | time_left | Pointer to an int to contain the ms left to the next run |
[out] | last_end | Pointer to a timeval structure to contain the next run time |
0 | Success |
-1 | Failure |
Definition at line 237 of file pjsip_scheduler.c.
References ao2_lock, ao2_unlock, AST_SIP_SCHED_TASK_DELAY, ast_tv(), ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_sip_sched_task::flags, ast_sip_sched_task::interval, ast_sip_sched_task::is_running, ast_sip_sched_task::last_end, ast_sip_sched_task::last_start, and ast_sip_sched_task::when_queued.
Referenced by ast_sip_sched_task_get_next_run(), ast_sip_sched_task_get_times(), and ast_sip_sched_task_get_times_by_name2().
int ast_sip_sched_task_get_times_by_name | ( | const char * | name, |
struct timeval * | when_queued, | ||
struct timeval * | last_start, | ||
struct timeval * | last_end | ||
) |
Gets the last start and end times of the task by name.
name | The task name | |
[out] | when_queued | Pointer to a timeval structure to contain the time when queued |
[out] | last_start | Pointer to a timeval structure to contain the time when last started |
[out] | last_end | Pointer to a timeval structure to contain the time when last ended |
0 | Success |
-1 | Failure |
Definition at line 327 of file pjsip_scheduler.c.
References ast_sip_sched_task_get_times_by_name2(), and NULL.
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 | ||
) |
Gets the queued, last start, last_end, time left, interval, next run by task name.
name | The task name | |
[out] | when_queued | Pointer to a timeval structure to contain the time when queued |
[out] | last_start | Pointer to a timeval structure to contain the time when last started |
[out] | last_end | Pointer to a timeval structure to contain the time when last ended |
[out] | interval | Pointer to an int to contain the interval in ms |
[out] | time_left | Pointer to an int to contain the ms left to the next run |
[out] | last_end | Pointer to a timeval structure to contain the next run time |
0 | Success |
-1 | Failure |
Definition at line 305 of file pjsip_scheduler.c.
References ao2_find, ao2_ref, ast_sip_sched_task_get_times2(), ast_strlen_zero, and OBJ_SEARCH_KEY.
Referenced by ast_sip_sched_task_get_times_by_name().
struct ast_sip_sched_task* ast_sip_schedule_task | ( | struct ast_taskprocessor * | serializer, |
int | interval, | ||
ast_sip_task | sip_task, | ||
const char * | name, | ||
void * | task_data, | ||
enum ast_sip_scheduler_task_flags | flags | ||
) |
Schedule a task to run in the res_pjsip thread pool.
serializer | The serializer to use. If NULL, don't use a serializer (see note below) |
interval | The invocation interval in milliseconds (see note below) |
sip_task | The task to invoke |
name | An optional name to associate with the task |
task_data | Optional data to pass to the task |
flags | One of enum ast_sip_scheduler_task_type |
Specifying a serializer guarantees serialized execution but NOT specifying a serializer may still result in tasks being effectively serialized if the thread pool is busy. The point of the serializer BTW is not to prevent parallel executions of the SAME task. That happens automatically (see below). It's to prevent the task from running at the same time as other work using the same serializer, whether or not it's being run by the scheduler.
The interval is used to calculate the next time the task should run. There are two models.
AST_SIP_SCHED_TASK_PERIODIC specifies that the invocations of the task occur at the specific interval. That is, every "interval" milliseconds, regardless of how long the task takes. If the task takes longer than interval, it will be scheduled at the next available multiple of interval. For exmaple: If the task has an interval of 60 seconds and the task takes 70 seconds, the next invocation will happen at 120 seconds.
AST_SIP_SCHED_TASK_DELAY specifies that the next invocation of the task should start at interval milliseconds after the current invocation has finished.
Definition at line 415 of file pjsip_scheduler.c.
References ao2_alloc, ao2_bump, ao2_link, ao2_lock, ao2_ref, ao2_unlink, ao2_unlock, ast_atomic_fetchadd_int(), ast_log, ast_samp2tv(), ast_sched_add(), AST_SIP_SCHED_TASK_DATA_AO2, AST_SIP_SCHED_TASK_DELAY, AST_SIP_SCHED_TASK_TRACK, ast_strlen_zero, ast_tv(), ast_tvadd(), ast_tvnow(), ast_sip_sched_task::current_scheduler_id, ast_sip_sched_task::flags, ID_LEN, ast_sip_sched_task::interval, ast_sip_sched_task::last_start, LOG_DEBUG, ast_sip_sched_task::name, ast_sip_sched_task::next_periodic, NULL, push_to_serializer(), schtd_dtor(), ast_sip_sched_task::serializer, ast_sip_sched_task::task, task_count, ast_sip_sched_task::task_data, and ast_sip_sched_task::when_queued.
Referenced by AST_TEST_DEFINE(), initial_notify_task(), scheduler(), sip_options_apply_aor_configuration(), and sip_options_contact_add_task().
int ast_sip_thread_is_servant | ( | void | ) |
Determine if the current thread is a SIP servant thread.
0 | This is not a SIP servant thread |
1 | This is a SIP servant thread |
Definition at line 5321 of file res_pjsip.c.
References ast_threadstorage_get(), servant_id_storage, and SIP_SERVANT_ID.
Referenced by ast_sip_push_task_wait_servant(), refer_progress_destroy(), and task_1().