mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-17 07:18:15 +00:00
res_pjsip: Create human friendly serializer names.
PJSIP name formats: pjsip/aor/<aor>-<seq> -- registrar thread pool serializer pjsip/default-<seq> -- default thread pool serializer pjsip/messaging -- messaging thread pool serializer pjsip/outreg/<registration>-<seq> -- outbound registration thread pool serializer pjsip/pubsub/<endpoint>-<seq> -- pubsub thread pool serializer pjsip/refer/<endpoint>-<seq> -- REFER thread pool serializer pjsip/session/<endpoint>-<seq> -- session thread pool serializer pjsip/websocket-<seq> -- websocket thread pool serializer Change-Id: Iff9df8da3ddae1132cb2ef65f64df0c465c5e084
This commit is contained in:
@@ -1106,32 +1106,36 @@ struct ast_sip_endpoint *ast_sip_get_artificial_endpoint(void);
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Create a new serializer for SIP tasks
|
* \brief Create a new serializer for SIP tasks
|
||||||
|
* \since 13.8.0
|
||||||
*
|
*
|
||||||
* See \ref ast_threadpool_serializer for more information on serializers.
|
* See \ref ast_threadpool_serializer for more information on serializers.
|
||||||
* SIP creates serializers so that tasks operating on similar data will run
|
* SIP creates serializers so that tasks operating on similar data will run
|
||||||
* in sequence.
|
* in sequence.
|
||||||
*
|
*
|
||||||
|
* \param name Name of the serializer. (must be unique)
|
||||||
|
*
|
||||||
* \retval NULL Failure
|
* \retval NULL Failure
|
||||||
* \retval non-NULL Newly-created serializer
|
* \retval non-NULL Newly-created serializer
|
||||||
*/
|
*/
|
||||||
struct ast_taskprocessor *ast_sip_create_serializer(void);
|
struct ast_taskprocessor *ast_sip_create_serializer(const char *name);
|
||||||
|
|
||||||
struct ast_serializer_shutdown_group;
|
struct ast_serializer_shutdown_group;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Create a new serializer for SIP tasks
|
* \brief Create a new serializer for SIP tasks
|
||||||
* \since 13.5.0
|
* \since 13.8.0
|
||||||
*
|
*
|
||||||
* See \ref ast_threadpool_serializer for more information on serializers.
|
* See \ref ast_threadpool_serializer for more information on serializers.
|
||||||
* SIP creates serializers so that tasks operating on similar data will run
|
* SIP creates serializers so that tasks operating on similar data will run
|
||||||
* in sequence.
|
* in sequence.
|
||||||
*
|
*
|
||||||
|
* \param name Name of the serializer. (must be unique)
|
||||||
* \param shutdown_group Group shutdown controller. (NULL if no group association)
|
* \param shutdown_group Group shutdown controller. (NULL if no group association)
|
||||||
*
|
*
|
||||||
* \retval NULL Failure
|
* \retval NULL Failure
|
||||||
* \retval non-NULL Newly-created serializer
|
* \retval non-NULL Newly-created serializer
|
||||||
*/
|
*/
|
||||||
struct ast_taskprocessor *ast_sip_create_serializer_group(struct ast_serializer_shutdown_group *shutdown_group);
|
struct ast_taskprocessor *ast_sip_create_serializer_group(const char *name, struct ast_serializer_shutdown_group *shutdown_group);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set a serializer on a SIP dialog so requests and responses are automatically serialized
|
* \brief Set a serializer on a SIP dialog so requests and responses are automatically serialized
|
||||||
|
|||||||
@@ -3433,23 +3433,14 @@ int ast_sip_append_body(pjsip_tx_data *tdata, const char *body_text)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ast_taskprocessor *ast_sip_create_serializer_group(struct ast_serializer_shutdown_group *shutdown_group)
|
struct ast_taskprocessor *ast_sip_create_serializer_group(const char *name, struct ast_serializer_shutdown_group *shutdown_group)
|
||||||
{
|
{
|
||||||
struct ast_taskprocessor *serializer;
|
return ast_threadpool_serializer_group(name, sip_threadpool, shutdown_group);
|
||||||
char name[AST_UUID_STR_LEN];
|
|
||||||
|
|
||||||
ast_uuid_generate_str(name, sizeof(name));
|
|
||||||
|
|
||||||
serializer = ast_threadpool_serializer_group(name, sip_threadpool, shutdown_group);
|
|
||||||
if (!serializer) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return serializer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ast_taskprocessor *ast_sip_create_serializer(void)
|
struct ast_taskprocessor *ast_sip_create_serializer(const char *name)
|
||||||
{
|
{
|
||||||
return ast_sip_create_serializer_group(NULL);
|
return ast_sip_create_serializer_group(name, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -3479,10 +3470,14 @@ static void serializer_pool_shutdown(void)
|
|||||||
*/
|
*/
|
||||||
static int serializer_pool_setup(void)
|
static int serializer_pool_setup(void)
|
||||||
{
|
{
|
||||||
|
char tps_name[AST_TASKPROCESSOR_MAX_NAME + 1];
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
for (idx = 0; idx < SERIALIZER_POOL_SIZE; ++idx) {
|
for (idx = 0; idx < SERIALIZER_POOL_SIZE; ++idx) {
|
||||||
serializer_pool[idx] = ast_sip_create_serializer();
|
/* Create name with seq number appended. */
|
||||||
|
ast_taskprocessor_build_name(tps_name, sizeof(tps_name), "pjsip/default");
|
||||||
|
|
||||||
|
serializer_pool[idx] = ast_sip_create_serializer(tps_name);
|
||||||
if (!serializer_pool[idx]) {
|
if (!serializer_pool[idx]) {
|
||||||
serializer_pool_shutdown();
|
serializer_pool_shutdown();
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -758,7 +758,7 @@ static int load_module(void)
|
|||||||
return AST_MODULE_LOAD_DECLINE;
|
return AST_MODULE_LOAD_DECLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
message_serializer = ast_sip_create_serializer();
|
message_serializer = ast_sip_create_serializer("pjsip/messaging");
|
||||||
if (!message_serializer) {
|
if (!message_serializer) {
|
||||||
ast_sip_unregister_service(&messaging_module);
|
ast_sip_unregister_service(&messaging_module);
|
||||||
ast_msg_tech_unregister(&msg_tech);
|
ast_msg_tech_unregister(&msg_tech);
|
||||||
|
|||||||
@@ -977,6 +977,7 @@ static void sip_outbound_registration_client_state_destroy(void *obj)
|
|||||||
static struct sip_outbound_registration_state *sip_outbound_registration_state_alloc(struct sip_outbound_registration *registration)
|
static struct sip_outbound_registration_state *sip_outbound_registration_state_alloc(struct sip_outbound_registration *registration)
|
||||||
{
|
{
|
||||||
struct sip_outbound_registration_state *state;
|
struct sip_outbound_registration_state *state;
|
||||||
|
char tps_name[AST_TASKPROCESSOR_MAX_NAME + 1];
|
||||||
|
|
||||||
state = ao2_alloc(sizeof(*state), sip_outbound_registration_state_destroy);
|
state = ao2_alloc(sizeof(*state), sip_outbound_registration_state_destroy);
|
||||||
if (!state) {
|
if (!state) {
|
||||||
@@ -989,7 +990,12 @@ static struct sip_outbound_registration_state *sip_outbound_registration_state_a
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->client_state->serializer = ast_sip_create_serializer_group(shutdown_group);
|
/* Create name with seq number appended. */
|
||||||
|
ast_taskprocessor_build_name(tps_name, sizeof(tps_name), "pjsip/outreg/%s",
|
||||||
|
ast_sorcery_object_get_id(registration));
|
||||||
|
|
||||||
|
state->client_state->serializer = ast_sip_create_serializer_group(tps_name,
|
||||||
|
shutdown_group);
|
||||||
if (!state->client_state->serializer) {
|
if (!state->client_state->serializer) {
|
||||||
ao2_cleanup(state);
|
ao2_cleanup(state);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -1234,6 +1234,7 @@ static void subscription_setup_dialog(struct sip_subscription_tree *sub_tree, pj
|
|||||||
static struct sip_subscription_tree *allocate_subscription_tree(struct ast_sip_endpoint *endpoint)
|
static struct sip_subscription_tree *allocate_subscription_tree(struct ast_sip_endpoint *endpoint)
|
||||||
{
|
{
|
||||||
struct sip_subscription_tree *sub_tree;
|
struct sip_subscription_tree *sub_tree;
|
||||||
|
char tps_name[AST_TASKPROCESSOR_MAX_NAME + 1];
|
||||||
|
|
||||||
sub_tree = ao2_alloc(sizeof *sub_tree, subscription_tree_destructor);
|
sub_tree = ao2_alloc(sizeof *sub_tree, subscription_tree_destructor);
|
||||||
if (!sub_tree) {
|
if (!sub_tree) {
|
||||||
@@ -1242,7 +1243,11 @@ static struct sip_subscription_tree *allocate_subscription_tree(struct ast_sip_e
|
|||||||
|
|
||||||
ast_module_ref(ast_module_info->self);
|
ast_module_ref(ast_module_info->self);
|
||||||
|
|
||||||
sub_tree->serializer = ast_sip_create_serializer();
|
/* Create name with seq number appended. */
|
||||||
|
ast_taskprocessor_build_name(tps_name, sizeof(tps_name), "pjsip/pubsub/%s",
|
||||||
|
ast_sorcery_object_get_id(endpoint));
|
||||||
|
|
||||||
|
sub_tree->serializer = ast_sip_create_serializer(tps_name);
|
||||||
if (!sub_tree->serializer) {
|
if (!sub_tree->serializer) {
|
||||||
ao2_ref(sub_tree, -1);
|
ao2_ref(sub_tree, -1);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -342,6 +342,7 @@ static int refer_progress_alloc(struct ast_sip_session *session, pjsip_rx_data *
|
|||||||
const pj_str_t str_true = { "true", 4 };
|
const pj_str_t str_true = { "true", 4 };
|
||||||
pjsip_tx_data *tdata;
|
pjsip_tx_data *tdata;
|
||||||
pjsip_hdr hdr_list;
|
pjsip_hdr hdr_list;
|
||||||
|
char tps_name[AST_TASKPROCESSOR_MAX_NAME + 1];
|
||||||
|
|
||||||
*progress = NULL;
|
*progress = NULL;
|
||||||
|
|
||||||
@@ -363,7 +364,11 @@ static int refer_progress_alloc(struct ast_sip_session *session, pjsip_rx_data *
|
|||||||
/* To prevent a potential deadlock we need the dialog so we can lock/unlock */
|
/* To prevent a potential deadlock we need the dialog so we can lock/unlock */
|
||||||
(*progress)->dlg = session->inv_session->dlg;
|
(*progress)->dlg = session->inv_session->dlg;
|
||||||
|
|
||||||
if (!((*progress)->serializer = ast_sip_create_serializer())) {
|
/* Create name with seq number appended. */
|
||||||
|
ast_taskprocessor_build_name(tps_name, sizeof(tps_name), "pjsip/refer/%s",
|
||||||
|
ast_sorcery_object_get_id(session->endpoint));
|
||||||
|
|
||||||
|
if (!((*progress)->serializer = ast_sip_create_serializer(tps_name))) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ static void serializer_destroy(void *obj)
|
|||||||
|
|
||||||
static struct serializer *serializer_create(const char *aor_name)
|
static struct serializer *serializer_create(const char *aor_name)
|
||||||
{
|
{
|
||||||
|
char tps_name[AST_TASKPROCESSOR_MAX_NAME + 1];
|
||||||
size_t size = strlen(aor_name) + 1;
|
size_t size = strlen(aor_name) + 1;
|
||||||
struct serializer *ser = ao2_alloc(
|
struct serializer *ser = ao2_alloc(
|
||||||
sizeof(*ser) + size, serializer_destroy);
|
sizeof(*ser) + size, serializer_destroy);
|
||||||
@@ -239,7 +240,11 @@ static struct serializer *serializer_create(const char *aor_name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ser->serializer = ast_sip_create_serializer())) {
|
/* Create name with seq number appended. */
|
||||||
|
ast_taskprocessor_build_name(tps_name, sizeof(tps_name), "pjsip/aor/%s",
|
||||||
|
aor_name);
|
||||||
|
|
||||||
|
if (!(ser->serializer = ast_sip_create_serializer(tps_name))) {
|
||||||
ao2_ref(ser, -1);
|
ao2_ref(ser, -1);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1266,6 +1266,7 @@ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint,
|
|||||||
RAII_VAR(struct ast_sip_session *, session, NULL, ao2_cleanup);
|
RAII_VAR(struct ast_sip_session *, session, NULL, ao2_cleanup);
|
||||||
struct ast_sip_session_supplement *iter;
|
struct ast_sip_session_supplement *iter;
|
||||||
int dsp_features = 0;
|
int dsp_features = 0;
|
||||||
|
char tps_name[AST_TASKPROCESSOR_MAX_NAME + 1];
|
||||||
|
|
||||||
session = ao2_alloc(sizeof(*session), session_destructor);
|
session = ao2_alloc(sizeof(*session), session_destructor);
|
||||||
if (!session) {
|
if (!session) {
|
||||||
@@ -1286,7 +1287,11 @@ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint,
|
|||||||
/* fill session->media with available types */
|
/* fill session->media with available types */
|
||||||
ao2_callback(sdp_handlers, OBJ_NODATA, add_session_media, session);
|
ao2_callback(sdp_handlers, OBJ_NODATA, add_session_media, session);
|
||||||
|
|
||||||
session->serializer = ast_sip_create_serializer();
|
/* Create name with seq number appended. */
|
||||||
|
ast_taskprocessor_build_name(tps_name, sizeof(tps_name), "pjsip/session/%s",
|
||||||
|
ast_sorcery_object_get_id(endpoint));
|
||||||
|
|
||||||
|
session->serializer = ast_sip_create_serializer(tps_name);
|
||||||
if (!session->serializer) {
|
if (!session->serializer) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -303,14 +303,22 @@ static int get_write_timeout(void)
|
|||||||
return write_timeout;
|
return write_timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
static struct ast_taskprocessor *create_websocket_serializer(void)
|
||||||
\brief WebSocket connection handler.
|
{
|
||||||
*/
|
char tps_name[AST_TASKPROCESSOR_MAX_NAME + 1];
|
||||||
|
|
||||||
|
/* Create name with seq number appended. */
|
||||||
|
ast_taskprocessor_build_name(tps_name, sizeof(tps_name), "pjsip/websocket");
|
||||||
|
|
||||||
|
return ast_sip_create_serializer(tps_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! \brief WebSocket connection handler. */
|
||||||
static void websocket_cb(struct ast_websocket *session, struct ast_variable *parameters, struct ast_variable *headers)
|
static void websocket_cb(struct ast_websocket *session, struct ast_variable *parameters, struct ast_variable *headers)
|
||||||
{
|
{
|
||||||
struct ast_taskprocessor *serializer = NULL;
|
struct ast_taskprocessor *serializer;
|
||||||
struct transport_create_data create_data;
|
struct transport_create_data create_data;
|
||||||
struct ws_transport *transport = NULL;
|
struct ws_transport *transport;
|
||||||
struct transport_read_data read_data;
|
struct transport_read_data read_data;
|
||||||
|
|
||||||
if (ast_websocket_set_nonblock(session)) {
|
if (ast_websocket_set_nonblock(session)) {
|
||||||
@@ -323,7 +331,8 @@ static void websocket_cb(struct ast_websocket *session, struct ast_variable *par
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(serializer = ast_sip_create_serializer())) {
|
serializer = create_websocket_serializer();
|
||||||
|
if (!serializer) {
|
||||||
ast_websocket_unref(session);
|
ast_websocket_unref(session);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user