@cryptotaxi247 / netdata-1 / commits / 11e4ac135

fix ACLK protocol version always parsed as 0 (#9502)

Timotej S committed Jul 8, 2020 at 16:20 UTC 11e4ac13577ebe65b24e7b2a7bd594ae5e128539
2 files changed +14 -1
aclk/agent_cloud_link.c
+1 -1
@@ -133,7 +133,7 @@ int cloud_to_agent_parse(JSON_ENTRY *e)
133 break;
134 case JSON_NUMBER:
135 if (!strcmp(e->name, "version")) {
136 - data->version = atoi(e->original_string);
136 + data->version = e->data.number;
137 break;
138 }
139 break;
libnetdata/json/json.c
+13
@@ -161,6 +161,16 @@ static inline void json_jsonc_set_boolean(JSON_ENTRY *e,int value) {
161 e->data.boolean = value;
162 }
163
164 +static inline void json_jsonc_set_integer(JSON_ENTRY *e, char *key, int64_t value) {
165 + size_t len = strlen(key);
166 + if(len > JSON_NAME_LEN)
167 + len = JSON_NAME_LEN;
168 + e->type = JSON_NUMBER;
169 + memcpy(e->name, key, len);
170 + e->name[len] = 0;
171 + e->data.number = value;
172 +}
173 +
174 /**
175 * Parse Array
176 *
@@ -449,6 +459,9 @@ size_t json_walk(json_object *t, void *callback_data, int (*callback_function)(s
459 } else if (type == json_type_boolean) {
460 json_jsonc_set_boolean(&e,json_object_get_boolean(val));
461 callback_function(&e);
462 + } else if (type == json_type_int) {
463 + json_jsonc_set_integer(&e,key,json_object_get_int64(val));
464 + callback_function(&e);
465 }
466 }
467