From 04f7d136d8ae4454cf403dc9bb24cf0fbbab4509 Mon Sep 17 00:00:00 2001 From: Alexei Gradinari Date: Tue, 24 Sep 2019 15:18:14 -0400 Subject: [PATCH] res_pjsip_pubsub: add endpoint to some warning There are some warning messages which are not informative without endpoint: "No registered subscribe handler for event presence.winfo" "No registered publish handler for event presence" This patch adds an endpoint name to these messages. Change-Id: Ia2811ec226d8a12659b4f9d4d224b48289650827 --- res/res_pjsip_pubsub.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c index 8f400b5b68..6074a566ba 100644 --- a/res/res_pjsip_pubsub.c +++ b/res/res_pjsip_pubsub.c @@ -758,7 +758,7 @@ static struct ast_sip_pubsub_body_generator *find_body_generator(char accept[AST size_t num_accept, const char *body_type); /*! \brief Retrieve a handler using the Event header of an rdata message */ -static struct ast_sip_subscription_handler *subscription_get_handler_from_rdata(pjsip_rx_data *rdata) +static struct ast_sip_subscription_handler *subscription_get_handler_from_rdata(pjsip_rx_data *rdata, const char *endpoint) { pjsip_event_hdr *event_header; char event[32]; @@ -766,14 +766,16 @@ static struct ast_sip_subscription_handler *subscription_get_handler_from_rdata( event_header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_event_name, rdata->msg_info.msg->hdr.next); if (!event_header) { - ast_log(LOG_WARNING, "Incoming SUBSCRIBE request with no Event header\n"); + ast_log(LOG_WARNING, "Incoming SUBSCRIBE request from %s with no Event header\n", + endpoint ? endpoint : "Unknown"); return NULL; } ast_copy_pj_str(event, &event_header->event_type, sizeof(event)); handler = find_sub_handler_for_event_name(event); if (!handler) { - ast_log(LOG_WARNING, "No registered subscribe handler for event %s\n", event); + ast_log(LOG_WARNING, "No registered subscribe handler for event %s from %s\n", event, + endpoint ? endpoint : "Unknown"); } return handler; @@ -1549,7 +1551,7 @@ static int sub_persistence_recreate(void *obj) */ AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(resource); - handler = subscription_get_handler_from_rdata(rdata); + handler = subscription_get_handler_from_rdata(rdata, persistence->endpoint); if (!handler || !handler->notifier) { ast_log(LOG_WARNING, "Failed recreating '%s' subscription: Could not get subscription handler.\n", persistence->endpoint); @@ -2982,7 +2984,7 @@ static pj_bool_t pubsub_on_rx_subscribe_request(pjsip_rx_data *rdata) } } - handler = subscription_get_handler_from_rdata(rdata); + handler = subscription_get_handler_from_rdata(rdata, ast_sorcery_object_get_id(endpoint)); if (!handler) { pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 489, NULL, NULL, NULL); return PJ_TRUE; @@ -3294,7 +3296,8 @@ static pj_bool_t pubsub_on_rx_publish_request(pjsip_rx_data *rdata) event_header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_event_name, rdata->msg_info.msg->hdr.next); if (!event_header) { - ast_log(LOG_WARNING, "Incoming PUBLISH request with no Event header\n"); + ast_log(LOG_WARNING, "Incoming PUBLISH request from %s with no Event header\n", + ast_sorcery_object_get_id(endpoint)); pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 489, NULL, NULL, NULL); return PJ_TRUE; } @@ -3302,7 +3305,8 @@ static pj_bool_t pubsub_on_rx_publish_request(pjsip_rx_data *rdata) handler = find_pub_handler(event); if (!handler) { - ast_log(LOG_WARNING, "No registered publish handler for event %s\n", event); + ast_log(LOG_WARNING, "No registered publish handler for event %s from %s\n", event, + ast_sorcery_object_get_id(endpoint)); pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 489, NULL, NULL, NULL); return PJ_TRUE; }