]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_pubsub: add endpoint to some warning
authorAlexei Gradinari <alex2grad@gmail.com>
Tue, 24 Sep 2019 19:18:14 +0000 (15:18 -0400)
committerAlexei Gradinari <alex2grad@gmail.com>
Fri, 27 Sep 2019 22:12:52 +0000 (17:12 -0500)
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

index 955db1d4e61f0b07ec10bc54f91fc86449099ce0..e26f25021a4558a8cd93b5d266eb72bd80a7d839 100644 (file)
@@ -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;
        }