diff options
author | Timotej S <6674623+underhood@users.noreply.github.com> | 2022-03-01 17:15:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-01 17:15:44 +0100 |
commit | f63fc2a5cd928048d47e5e62a0d757ab4be5f8e5 (patch) | |
tree | 16955865f319694a4248f607ece1671e6bf6d8e0 /aclk/aclk_tx_msgs.c | |
parent | 3e1fa32e5c9081d2630d4d964bfa811f0f270f55 (diff) |
Use the new error mechanism in case host not found (#12277)
Diffstat (limited to 'aclk/aclk_tx_msgs.c')
-rw-r--r-- | aclk/aclk_tx_msgs.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/aclk/aclk_tx_msgs.c b/aclk/aclk_tx_msgs.c index 0dbe70c302..9ade2e12ef 100644 --- a/aclk/aclk_tx_msgs.c +++ b/aclk/aclk_tx_msgs.c @@ -325,6 +325,18 @@ void aclk_send_alarm_metadata(mqtt_wss_client client, int metadata_submitted) buffer_free(local_buffer); } +void aclk_http_msg_v2_err(mqtt_wss_client client, const char *topic, const char *msg_id, int http_code, const char *payload, size_t payload_len) +{ + json_object *tmp, *msg; + msg = create_hdr("http", msg_id, 0, 0, 2); + tmp = json_object_new_int(http_code); + json_object_object_add(msg, "http-code", tmp); + if (aclk_send_message_with_bin_payload(client, msg, topic, payload, payload_len)) { + error("Failed to send cancelation message for http reply"); + } + json_object_put(msg); +} + void aclk_http_msg_v2(mqtt_wss_client client, const char *topic, const char *msg_id, usec_t t_exec, usec_t created, int http_code, const char *payload, size_t payload_len) { json_object *tmp, *msg; @@ -343,15 +355,8 @@ void aclk_http_msg_v2(mqtt_wss_client client, const char *topic, const char *msg int rc = aclk_send_message_with_bin_payload(client, msg, topic, payload, payload_len); json_object_put(msg); - if (rc) { - msg = create_hdr("http", msg_id, 0, 0, 2); - tmp = json_object_new_int(rc); - json_object_object_add(msg, "http-code", tmp); - if (aclk_send_message_with_bin_payload(client, msg, topic, payload, payload_len)) { - error("Failed to send cancelation message for http reply"); - } - json_object_put(msg); - } + if (rc) + aclk_http_msg_v2_err(client, topic, msg_id, rc, payload, payload_len); } void aclk_chart_msg(mqtt_wss_client client, RRDHOST *host, const char *chart) |