]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_geolocation: Change some notices to debugs.
authorNaveen Albert <asterisk@phreaknet.org>
Mon, 19 Sep 2022 17:35:40 +0000 (17:35 +0000)
committerGeorge Joseph <gjoseph@digium.com>
Wed, 28 Sep 2022 12:21:46 +0000 (07:21 -0500)
If geolocation is not in use for an endpoint, the NOTICE
log level is currently spammed with messages about this,
even though nothing is wrong and these messages provide
no real value. These log messages are therefore changed
to debugs.

ASTERISK-30241 #close

Change-Id: I656b355d812f67cc0f0fdf09b00b0e1458598bb4
(cherry picked from commit fb603e58b552c3d937a25bd81247298f1a548319)

res/res_pjsip_geolocation.c

index d0e8d465d35b832c750415c7834ac2e9358c07c3..422c56d5f9a9421cbf6a56f93fd24009027f7e4d 100644 (file)
@@ -145,7 +145,7 @@ static int handle_incoming_request(struct ast_sip_session *session, struct pjsip
        char *geoloc_routing_hdr_value = NULL;
        char *geoloc_uri = NULL;
        int rc = 0;
-       RAII_VAR(struct ast_str *, buf, ast_str_create(1024), ast_free);
+       RAII_VAR(struct ast_str *, buf, NULL, ast_free);
        pjsip_generic_string_hdr *geoloc_hdr = NULL;
        pjsip_generic_string_hdr *geoloc_routing_hdr = NULL;
        SCOPE_ENTER(3, "%s\n", session_name);
@@ -191,7 +191,7 @@ static int handle_incoming_request(struct ast_sip_session *session, struct pjsip
                                "Done.\n", session_name,
                                PJSTR_PRINTF_VAR(geoloc_hdr->hvalue));
                } else {
-                       SCOPE_EXIT_LOG_RTN_VALUE(0, LOG_NOTICE, "%s: Endpoint has no geoloc_incoming_call_profile. "
+                       SCOPE_EXIT_RTN_VALUE(0, "%s: Endpoint has no geoloc_incoming_call_profile. "
                                "Done.\n", session_name);
                }
        }
@@ -209,6 +209,11 @@ static int handle_incoming_request(struct ast_sip_session *session, struct pjsip
                }
        }
 
+       buf = ast_str_create(1024);
+       if (!buf) {
+               SCOPE_EXIT_LOG_RTN_VALUE(0, LOG_WARNING, "%s: Unable to allocate buf\n", session_name);
+       }
+
        if (config_profile->precedence != AST_GEOLOC_PRECED_DISCARD_CONFIG) {
                config_eprofile = ast_geoloc_eprofile_create_from_profile(config_profile);
                if (!config_eprofile) {
@@ -469,7 +474,7 @@ static void handle_outgoing_request(struct ast_sip_session *session, struct pjsi
        RAII_VAR(struct ast_geoloc_eprofile *, config_eprofile, NULL, ao2_cleanup);
        RAII_VAR(struct ast_geoloc_eprofile *, incoming_eprofile, NULL, ao2_cleanup);
        struct ast_geoloc_eprofile *final_eprofile = NULL;
-       RAII_VAR(struct ast_str *, buf, ast_str_create(1024), ast_free);
+       RAII_VAR(struct ast_str *, buf, NULL, ast_free);
        struct ast_datastore *ds = NULL;  /* The channel cleans up ds */
        pjsip_msg_body *orig_body = NULL;
        pjsip_generic_string_hdr *geoloc_hdr = NULL;
@@ -478,11 +483,6 @@ static void handle_outgoing_request(struct ast_sip_session *session, struct pjsi
        const char *uri;
        SCOPE_ENTER(3, "%s\n", session_name);
 
-       if (!buf) {
-               SCOPE_EXIT_LOG_RTN(LOG_WARNING, "%s: Unable to allocate buf\n",
-                       session_name);
-       }
-
        if (!endpoint) {
                SCOPE_EXIT_LOG_RTN(LOG_WARNING, "%s: Session has no endpoint.  Skipping.\n",
                        session_name);
@@ -494,8 +494,8 @@ static void handle_outgoing_request(struct ast_sip_session *session, struct pjsi
        }
 
        if (ast_strlen_zero(endpoint->geoloc_outgoing_call_profile)) {
-                       SCOPE_EXIT_LOG_RTN(LOG_NOTICE, "%s: Endpoint has no geoloc_outgoing_call_profile. "
-                               "Skipping.\n", session_name);
+               SCOPE_EXIT_RTN("%s: Endpoint has no geoloc_outgoing_call_profile. Skipping.\n",
+                       session_name);
        }
 
        config_profile = ast_geoloc_get_profile(endpoint->geoloc_outgoing_call_profile);
@@ -578,6 +578,11 @@ static void handle_outgoing_request(struct ast_sip_session *session, struct pjsi
                ast_geoloc_eprofile_refresh_location(final_eprofile);
        }
 
+       buf = ast_str_create(1024);
+       if (!buf) {
+               SCOPE_EXIT_LOG_RTN(LOG_WARNING, "%s: Unable to allocate buf\n", session_name);
+       }
+
        if (final_eprofile->format == AST_GEOLOC_FORMAT_URI) {
                uri = ast_geoloc_eprofile_to_uri(final_eprofile, channel, &buf, session_name);
                if (!uri) {