mirror of
https://github.com/netdata/netdata.git
synced 2025-04-16 10:31:07 +00:00
prevent crash on rrdcontext apis when rrdcontexts is not initialized (#13578)
prevent crash
This commit is contained in:
parent
96e64963ef
commit
84b07e6e28
1 changed files with 10 additions and 0 deletions
|
@ -2377,6 +2377,11 @@ static inline int rrdcontext_to_json_callback(const char *id, void *value, void
|
|||
}
|
||||
|
||||
int rrdcontext_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, RRDCONTEXT_TO_JSON_OPTIONS options, const char *context, SIMPLE_PATTERN *chart_label_key, SIMPLE_PATTERN *chart_labels_filter, SIMPLE_PATTERN *chart_dimensions) {
|
||||
if(!host->rrdctx) {
|
||||
error("%s(): request for host '%s' that does not have rrdcontexts initialized.", __FUNCTION__, host->hostname);
|
||||
return HTTP_RESP_NOT_FOUND;
|
||||
}
|
||||
|
||||
RRDCONTEXT_ACQUIRED *rca = (RRDCONTEXT_ACQUIRED *)dictionary_get_and_acquire_item((DICTIONARY *)host->rrdctx, context);
|
||||
if(!rca) return HTTP_RESP_NOT_FOUND;
|
||||
|
||||
|
@ -2412,6 +2417,11 @@ int rrdcontext_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, R
|
|||
}
|
||||
|
||||
int rrdcontexts_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, RRDCONTEXT_TO_JSON_OPTIONS options, SIMPLE_PATTERN *chart_label_key, SIMPLE_PATTERN *chart_labels_filter, SIMPLE_PATTERN *chart_dimensions) {
|
||||
if(!host->rrdctx) {
|
||||
error("%s(): request for host '%s' that does not have rrdcontexts initialized.", __FUNCTION__, host->hostname);
|
||||
return HTTP_RESP_NOT_FOUND;
|
||||
}
|
||||
|
||||
char node_uuid[UUID_STR_LEN] = "";
|
||||
|
||||
if(host->node_id)
|
||||
|
|
Loading…
Add table
Reference in a new issue