diff options
-rw-r--r-- | src/rest.c | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -954,7 +954,7 @@ static int og_json_os_array_get(struct og_dbi *dbi, json_t *array, const char *i static int og_cmd_get_session(json_t *element, struct og_msg_params *params, char *buffer_reply) { - json_t *value, *root, *array; + json_t *value, *root, *array, *client_data, *partitions; struct og_dbi *dbi; const char *key; int err = 0, i; @@ -992,11 +992,31 @@ static int og_cmd_get_session(json_t *element, struct og_msg_params *params, } for (i = 0; i < params->ips_array_len; i++) { - if (og_json_os_array_get(dbi, array, params->ips_array[i]) < 0) { + client_data = json_object(); + if (!client_data) { json_decref(array); og_dbi_close(dbi); return -1; } + json_object_set_new(client_data, "addr", json_string(params->ips_array[i])); + + partitions = json_array(); + if (!partitions) { + json_decref(client_data); + json_decref(array); + og_dbi_close(dbi); + return -1; + } + + if (og_json_os_array_get(dbi, partitions, params->ips_array[i]) < 0) { + json_decref(partitions); + json_decref(client_data); + json_decref(array); + og_dbi_close(dbi); + return -1; + } + json_object_set_new(client_data, "partitions", partitions); + json_array_append_new(array, client_data); } og_dbi_close(dbi); |