mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-16 17:53:15 +00:00
Merge "res_pjsip_pubsub.c: Eliminate trivial SCOPED_LOCK usage." into 13
This commit is contained in:
@@ -1039,14 +1039,16 @@ static int datastore_cmp(void *obj, void *arg, int flags)
|
|||||||
|
|
||||||
static void add_subscription(struct sip_subscription_tree *obj)
|
static void add_subscription(struct sip_subscription_tree *obj)
|
||||||
{
|
{
|
||||||
SCOPED_LOCK(lock, &subscriptions, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
|
AST_RWLIST_WRLOCK(&subscriptions);
|
||||||
AST_RWLIST_INSERT_TAIL(&subscriptions, obj, next);
|
AST_RWLIST_INSERT_TAIL(&subscriptions, obj, next);
|
||||||
|
AST_RWLIST_UNLOCK(&subscriptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_subscription(struct sip_subscription_tree *obj)
|
static void remove_subscription(struct sip_subscription_tree *obj)
|
||||||
{
|
{
|
||||||
struct sip_subscription_tree *i;
|
struct sip_subscription_tree *i;
|
||||||
SCOPED_LOCK(lock, &subscriptions, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
|
|
||||||
|
AST_RWLIST_WRLOCK(&subscriptions);
|
||||||
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&subscriptions, i, next) {
|
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&subscriptions, i, next) {
|
||||||
if (i == obj) {
|
if (i == obj) {
|
||||||
AST_RWLIST_REMOVE_CURRENT(next);
|
AST_RWLIST_REMOVE_CURRENT(next);
|
||||||
@@ -1058,6 +1060,7 @@ static void remove_subscription(struct sip_subscription_tree *obj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AST_RWLIST_TRAVERSE_SAFE_END;
|
AST_RWLIST_TRAVERSE_SAFE_END;
|
||||||
|
AST_RWLIST_UNLOCK(&subscriptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy_subscription(struct ast_sip_subscription *sub)
|
static void destroy_subscription(struct ast_sip_subscription *sub)
|
||||||
@@ -1600,18 +1603,19 @@ static int for_each_subscription(on_subscription_t on_subscription, void *arg)
|
|||||||
{
|
{
|
||||||
int num = 0;
|
int num = 0;
|
||||||
struct sip_subscription_tree *i;
|
struct sip_subscription_tree *i;
|
||||||
SCOPED_LOCK(lock, &subscriptions, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
|
|
||||||
|
|
||||||
if (!on_subscription) {
|
if (!on_subscription) {
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AST_RWLIST_RDLOCK(&subscriptions);
|
||||||
AST_RWLIST_TRAVERSE(&subscriptions, i, next) {
|
AST_RWLIST_TRAVERSE(&subscriptions, i, next) {
|
||||||
if (on_subscription(i, arg)) {
|
if (on_subscription(i, arg)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++num;
|
++num;
|
||||||
}
|
}
|
||||||
|
AST_RWLIST_UNLOCK(&subscriptions);
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2554,8 +2558,9 @@ static int publication_cmp_fn(void *obj, void *arg, int flags)
|
|||||||
|
|
||||||
static void publish_add_handler(struct ast_sip_publish_handler *handler)
|
static void publish_add_handler(struct ast_sip_publish_handler *handler)
|
||||||
{
|
{
|
||||||
SCOPED_LOCK(lock, &publish_handlers, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
|
AST_RWLIST_WRLOCK(&publish_handlers);
|
||||||
AST_RWLIST_INSERT_TAIL(&publish_handlers, handler, next);
|
AST_RWLIST_INSERT_TAIL(&publish_handlers, handler, next);
|
||||||
|
AST_RWLIST_UNLOCK(&publish_handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_sip_register_publish_handler(struct ast_sip_publish_handler *handler)
|
int ast_sip_register_publish_handler(struct ast_sip_publish_handler *handler)
|
||||||
@@ -2582,7 +2587,8 @@ int ast_sip_register_publish_handler(struct ast_sip_publish_handler *handler)
|
|||||||
void ast_sip_unregister_publish_handler(struct ast_sip_publish_handler *handler)
|
void ast_sip_unregister_publish_handler(struct ast_sip_publish_handler *handler)
|
||||||
{
|
{
|
||||||
struct ast_sip_publish_handler *iter;
|
struct ast_sip_publish_handler *iter;
|
||||||
SCOPED_LOCK(lock, &publish_handlers, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
|
|
||||||
|
AST_RWLIST_WRLOCK(&publish_handlers);
|
||||||
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&publish_handlers, iter, next) {
|
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&publish_handlers, iter, next) {
|
||||||
if (handler == iter) {
|
if (handler == iter) {
|
||||||
AST_RWLIST_REMOVE_CURRENT(next);
|
AST_RWLIST_REMOVE_CURRENT(next);
|
||||||
@@ -2592,27 +2598,30 @@ void ast_sip_unregister_publish_handler(struct ast_sip_publish_handler *handler)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AST_RWLIST_TRAVERSE_SAFE_END;
|
AST_RWLIST_TRAVERSE_SAFE_END;
|
||||||
|
AST_RWLIST_UNLOCK(&publish_handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
AST_RWLIST_HEAD_STATIC(subscription_handlers, ast_sip_subscription_handler);
|
AST_RWLIST_HEAD_STATIC(subscription_handlers, ast_sip_subscription_handler);
|
||||||
|
|
||||||
static void sub_add_handler(struct ast_sip_subscription_handler *handler)
|
static void sub_add_handler(struct ast_sip_subscription_handler *handler)
|
||||||
{
|
{
|
||||||
SCOPED_LOCK(lock, &subscription_handlers, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
|
AST_RWLIST_WRLOCK(&subscription_handlers);
|
||||||
AST_RWLIST_INSERT_TAIL(&subscription_handlers, handler, next);
|
AST_RWLIST_INSERT_TAIL(&subscription_handlers, handler, next);
|
||||||
ast_module_ref(ast_module_info->self);
|
ast_module_ref(ast_module_info->self);
|
||||||
|
AST_RWLIST_UNLOCK(&subscription_handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ast_sip_subscription_handler *find_sub_handler_for_event_name(const char *event_name)
|
static struct ast_sip_subscription_handler *find_sub_handler_for_event_name(const char *event_name)
|
||||||
{
|
{
|
||||||
struct ast_sip_subscription_handler *iter;
|
struct ast_sip_subscription_handler *iter;
|
||||||
SCOPED_LOCK(lock, &subscription_handlers, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
|
|
||||||
|
|
||||||
|
AST_RWLIST_RDLOCK(&subscription_handlers);
|
||||||
AST_RWLIST_TRAVERSE(&subscription_handlers, iter, next) {
|
AST_RWLIST_TRAVERSE(&subscription_handlers, iter, next) {
|
||||||
if (!strcmp(iter->event_name, event_name)) {
|
if (!strcmp(iter->event_name, event_name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AST_RWLIST_UNLOCK(&subscription_handlers);
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2651,7 +2660,8 @@ int ast_sip_register_subscription_handler(struct ast_sip_subscription_handler *h
|
|||||||
void ast_sip_unregister_subscription_handler(struct ast_sip_subscription_handler *handler)
|
void ast_sip_unregister_subscription_handler(struct ast_sip_subscription_handler *handler)
|
||||||
{
|
{
|
||||||
struct ast_sip_subscription_handler *iter;
|
struct ast_sip_subscription_handler *iter;
|
||||||
SCOPED_LOCK(lock, &subscription_handlers, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
|
|
||||||
|
AST_RWLIST_WRLOCK(&subscription_handlers);
|
||||||
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&subscription_handlers, iter, next) {
|
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&subscription_handlers, iter, next) {
|
||||||
if (handler == iter) {
|
if (handler == iter) {
|
||||||
AST_RWLIST_REMOVE_CURRENT(next);
|
AST_RWLIST_REMOVE_CURRENT(next);
|
||||||
@@ -2660,6 +2670,7 @@ void ast_sip_unregister_subscription_handler(struct ast_sip_subscription_handler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AST_RWLIST_TRAVERSE_SAFE_END;
|
AST_RWLIST_TRAVERSE_SAFE_END;
|
||||||
|
AST_RWLIST_UNLOCK(&subscription_handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ast_sip_pubsub_body_generator *find_body_generator_type_subtype_nolock(const char *type, const char *subtype)
|
static struct ast_sip_pubsub_body_generator *find_body_generator_type_subtype_nolock(const char *type, const char *subtype)
|
||||||
@@ -2888,8 +2899,8 @@ static pj_bool_t pubsub_on_rx_subscribe_request(pjsip_rx_data *rdata)
|
|||||||
static struct ast_sip_publish_handler *find_pub_handler(const char *event)
|
static struct ast_sip_publish_handler *find_pub_handler(const char *event)
|
||||||
{
|
{
|
||||||
struct ast_sip_publish_handler *iter = NULL;
|
struct ast_sip_publish_handler *iter = NULL;
|
||||||
SCOPED_LOCK(lock, &publish_handlers, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
|
|
||||||
|
|
||||||
|
AST_RWLIST_RDLOCK(&publish_handlers);
|
||||||
AST_RWLIST_TRAVERSE(&publish_handlers, iter, next) {
|
AST_RWLIST_TRAVERSE(&publish_handlers, iter, next) {
|
||||||
if (strcmp(event, iter->event_name)) {
|
if (strcmp(event, iter->event_name)) {
|
||||||
ast_debug(3, "Event %s does not match %s\n", event, iter->event_name);
|
ast_debug(3, "Event %s does not match %s\n", event, iter->event_name);
|
||||||
@@ -2898,6 +2909,7 @@ static struct ast_sip_publish_handler *find_pub_handler(const char *event)
|
|||||||
ast_debug(3, "Event name match: %s = %s\n", event, iter->event_name);
|
ast_debug(3, "Event name match: %s = %s\n", event, iter->event_name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
AST_RWLIST_UNLOCK(&publish_handlers);
|
||||||
|
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
@@ -3261,8 +3273,8 @@ int ast_sip_pubsub_register_body_generator(struct ast_sip_pubsub_body_generator
|
|||||||
void ast_sip_pubsub_unregister_body_generator(struct ast_sip_pubsub_body_generator *generator)
|
void ast_sip_pubsub_unregister_body_generator(struct ast_sip_pubsub_body_generator *generator)
|
||||||
{
|
{
|
||||||
struct ast_sip_pubsub_body_generator *iter;
|
struct ast_sip_pubsub_body_generator *iter;
|
||||||
SCOPED_LOCK(lock, &body_generators, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
|
|
||||||
|
|
||||||
|
AST_RWLIST_WRLOCK(&body_generators);
|
||||||
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&body_generators, iter, list) {
|
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&body_generators, iter, list) {
|
||||||
if (iter == generator) {
|
if (iter == generator) {
|
||||||
AST_LIST_REMOVE_CURRENT(list);
|
AST_LIST_REMOVE_CURRENT(list);
|
||||||
@@ -3270,6 +3282,7 @@ void ast_sip_pubsub_unregister_body_generator(struct ast_sip_pubsub_body_generat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AST_RWLIST_TRAVERSE_SAFE_END;
|
AST_RWLIST_TRAVERSE_SAFE_END;
|
||||||
|
AST_RWLIST_UNLOCK(&body_generators);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_sip_pubsub_register_body_supplement(struct ast_sip_pubsub_body_supplement *supplement)
|
int ast_sip_pubsub_register_body_supplement(struct ast_sip_pubsub_body_supplement *supplement)
|
||||||
@@ -3284,8 +3297,8 @@ int ast_sip_pubsub_register_body_supplement(struct ast_sip_pubsub_body_supplemen
|
|||||||
void ast_sip_pubsub_unregister_body_supplement(struct ast_sip_pubsub_body_supplement *supplement)
|
void ast_sip_pubsub_unregister_body_supplement(struct ast_sip_pubsub_body_supplement *supplement)
|
||||||
{
|
{
|
||||||
struct ast_sip_pubsub_body_supplement *iter;
|
struct ast_sip_pubsub_body_supplement *iter;
|
||||||
SCOPED_LOCK(lock, &body_supplements, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
|
|
||||||
|
|
||||||
|
AST_RWLIST_WRLOCK(&body_supplements);
|
||||||
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&body_supplements, iter, list) {
|
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&body_supplements, iter, list) {
|
||||||
if (iter == supplement) {
|
if (iter == supplement) {
|
||||||
AST_LIST_REMOVE_CURRENT(list);
|
AST_LIST_REMOVE_CURRENT(list);
|
||||||
@@ -3293,6 +3306,7 @@ void ast_sip_pubsub_unregister_body_supplement(struct ast_sip_pubsub_body_supple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AST_RWLIST_TRAVERSE_SAFE_END;
|
AST_RWLIST_TRAVERSE_SAFE_END;
|
||||||
|
AST_RWLIST_UNLOCK(&body_supplements);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ast_sip_subscription_get_body_type(struct ast_sip_subscription *sub)
|
const char *ast_sip_subscription_get_body_type(struct ast_sip_subscription *sub)
|
||||||
|
Reference in New Issue
Block a user